RynthSuite as of 2026-11-08 (internal c9af5266): release 2026.11.8.2

This commit is contained in:
Tom Bohar 2026-11-08 21:05:44 -05:00
commit 81de36a2e5
12 changed files with 764 additions and 26 deletions

View file

@ -5313,8 +5313,12 @@ public partial class CombatManager : IDisposable
// swap is under way: a launcher whose ammo already went into the pack is never kept.
double minGain = _settings.WeaponSwapMinGainPct > 0 && SwapHoldsAllowed(InHandWeaponId())
? _settings.WeaponSwapMinGainPct / 100.0 : 0;
return WeaponPlanner.Choose(listed, ruleElement, weak, e => CanCastElement(e, rule),
var plan = WeaponPlanner.Choose(listed, ruleElement, weak, e => CanCastElement(e, rule),
fixedId, fixedSource, learnedId, ctype, fixedIsDefault, minGain, PreferredDamageFor(rule));
// A damage type on the Default row is every monster's, not a choice for this one.
if (plan.ForThisMonster && !ownRule && (fixedId == 0 || fixedIsDefault))
plan = plan with { ForThisMonster = false };
return plan;
}
/// <summary>The preferred damage type for a fight: the rule's own, else (Auto) the Default row's.</summary>
@ -6025,11 +6029,18 @@ public partial class CombatManager : IDisposable
/// Asks the swap tracker about <paramref name="chosenId"/> with <paramref name="inHandId"/>
/// in hand, after folding in a server refusal of the wield in flight. Logs a give-up once.
/// </summary>
private WeaponSwapTracker.Step SwapStep(int chosenId, int inHandId)
private WeaponSwapTracker.Step SwapStep(int chosenId, int inHandId) => SwapStepFor(chosenId, inHandId, false, null);
/// <summary>
/// <see cref="SwapStep"/> for the fight's chosen weapon. <paramref name="forThisMonster"/>: the
/// player set it for the target (see WeaponSwapTracker.Next); <paramref name="source"/> (the
/// plan's reason) goes on a hold's log line.
/// </summary>
private WeaponSwapTracker.Step SwapStepFor(int chosenId, int inHandId, bool forThisMonster, string? source)
{
DateTime now = RynthClock.Now;
FoldServerAnswer(SwapTracker, now);
var step = SwapTracker.Next(chosenId, inHandId, now, WeaponName, forKey: activeTargetId);
var step = SwapTracker.Next(chosenId, inHandId, now, WeaponName, forKey: activeTargetId, forThisMonster: forThisMonster);
if (SwapTracker.Notice != null)
{
_host.Log($"[EquipDiag] {SwapTracker.Notice}");
@ -6046,7 +6057,10 @@ public partial class CombatManager : IDisposable
if (step == WeaponSwapTracker.Step.Hold && (RynthClock.Now - _lastSwapHoldLogAt).TotalSeconds > 10)
{
_lastSwapHoldLogAt = RynthClock.Now;
_host.Log($"[EquipDiag] keeping 0x{(uint)inHandId:X8} '{WeaponName(inHandId)}' instead of 0x{(uint)chosenId:X8} '{WeaponName(chosenId)}' ({SwapTracker.HoldReason})");
// The chosen weapon's source too (2026-11-08): R-20261107-141028-b33e's log couldn't say
// whether the held Fire Staff was the monster's own pick or the weakness's.
string wanted = string.IsNullOrEmpty(source) ? "" : $"; wanted for: {source}";
_host.Log($"[EquipDiag] keeping 0x{(uint)inHandId:X8} '{WeaponName(inHandId)}' instead of 0x{(uint)chosenId:X8} '{WeaponName(chosenId)}' ({SwapTracker.HoldReason}{wanted})");
}
return step;
}
@ -6257,7 +6271,7 @@ public partial class CombatManager : IDisposable
/// weapon can't turn into a UseObject that takes it off. Wand-for-wand used to never
/// happen: Magic mode was trusted, so whatever wand was in hand stayed there (2026-09-30).
/// </summary>
private bool SwapToChosenSameKind(int weaponId, int desiredMode)
private bool SwapToChosenSameKind(int weaponId, int desiredMode, bool forThisMonster = false, string? source = null)
{
int inHand = InHandWeaponId();
// Empty hands in the stance already, the chosen weapon positively in a pack: wield it. The
@ -6283,7 +6297,7 @@ public partial class CombatManager : IDisposable
if (WeaponKind(inHand) != desiredMode) return false; // a cross-kind case; the branches below handle it
_equippedWeaponId = inHand;
switch (SwapStep(weaponId, inHand))
switch (SwapStepFor(weaponId, inHand, forThisMonster, source))
{
case WeaponSwapTracker.Step.Wait: return true;
case WeaponSwapTracker.Step.Swap:
@ -6385,6 +6399,11 @@ public partial class CombatManager : IDisposable
int inHand = InHandWeaponId();
bool allowWield = true;
_curOffhandMode = OffhandChoiceFor(target, rule).Mode;
// The player set this weapon for this monster (R-20261107-141028-b33e): the swap tracker's
// window cap lets it in for a new target. Only while it is still the plan's weapon (not a
// dual-wield stand-in or the wand from FindWandInItems).
var ownPlan = PlanFor(target, rule);
bool ForThisMonster(int id) => ownPlan.ForThisMonster && ownPlan.WeaponId == id;
// Dual wield: the chosen weapon already swings in the off hand, beside another listed
// one-handed weapon in the main hand. Fight with both rather than moving it across.
@ -6427,7 +6446,7 @@ public partial class CombatManager : IDisposable
}
else if (inHand != targetWeaponId)
{
var step = SwapStep(targetWeaponId, inHand);
var step = SwapStepFor(targetWeaponId, inHand, ForThisMonster(targetWeaponId), weaponSource);
if (step == WeaponSwapTracker.Step.Wait) { if (inHand != 0) _equippedWeaponId = inHand; return false; }
if (step == WeaponSwapTracker.Step.Swap && inHand != 0
&& SwapDeferReason(target, targetWeaponId, inHand, out bool settling) is string defer)
@ -6625,7 +6644,7 @@ public partial class CombatManager : IDisposable
// pick and the Damage tab choose between weapons of one kind, and trusting the
// mode here meant the chosen one was never put in hand. That covered melee only;
// a wand in hand in Magic mode was kept whatever the list said (2026-09-30).
if (SwapToChosenSameKind(targetWeaponId, desiredMode))
if (SwapToChosenSameKind(targetWeaponId, desiredMode, ForThisMonster(targetWeaponId), weaponSource))
return false;
// The chosen weapon read in hand (the wield-location read was only late): a launcher's ammo,
// then the off hand.

View file

@ -84,7 +84,8 @@ internal static class PetChoice
if (choice.StartsWith("I:", StringComparison.Ordinal)
&& int.TryParse(choice.AsSpan(2), out int wantId))
{
// Same essence by id, or (after it was replaced) by the name it had.
// Same essence by id. A replaced essence's pick arrives already pointed at its
// same-named successor (PetManager.OrderDevicesForTarget; this matched the id only).
int idx = list.FindIndex(d => d.Id == wantId);
reason = idx >= 0 ? $"picked {list[idx].Name}" : "picked essence not in pack, using Auto";
if (idx >= 0)

View file

@ -0,0 +1,92 @@
using System.Collections.Generic;
using RynthCore.PluginSdk;
namespace RynthCore.Plugin.RynthAi;
/// <summary>
/// Whether an essence summons a combat pet, from the client's data, not its name (2026-11-08,
/// R-20261108-215240-651b: on 2026.11.8.1 the combat summoner kept summoning a "Common Golem
/// Essence", a passive pet that never fights or despawns, ahead of the two combat pets the player
/// had ticked. It was in the Items list as a Pet entry because its name ends in "Essence", and Auto
/// put it first because "Golem" reads as Bludgeon).
///
/// Every combat pet device in the ACE world data (259 of them) carries a charge count (Structure /
/// MaxStructure), a Summoning use requirement (UseRequiresSkill 54) and the summoning-gem icon
/// underlay; none of the 29 passive ones (crates, eggs) carries any of these, and the client is sent
/// all three. That report's golem essence had been appraised (5 ints, no charge count: "charges=-1")
/// before it was used. ACECustom's essences are combat by their wcid block, bond or potency.
///
/// So an essence is <see cref="Verdict.Combat"/> on any of those signs, <see cref="Verdict.NotCombat"/>
/// when it has been appraised and shows none of them, and <see cref="Verdict.Unknown"/> before its
/// appraisal (nothing is concluded from a read the client may not have yet). An essence whose use
/// brought a pet out and that then judges NotCombat is learned for the session
/// (<see cref="Learn"/>), which the Mini Remote Pets tab reads to show it as Cosmetic.
/// </summary>
internal static class PetDeviceKind
{
internal enum Verdict { Unknown, Combat, NotCombat }
private const uint IntMaxStructure = 91;
private const uint IntStructure = 92;
private const uint IntUseRequiresSkill = 366;
private const uint IntUseRequiresSkillSpec = 368;
private const uint IntBondLevel = 9053; // ACECustom pet essence
private const uint IntPotencyStored = 9056; // ACECustom pet essence
private const int SkillSummoning = 54;
private const uint DidIconUnderlay = 52;
private const uint SummonGemUnderlay = 0x007420;
private static readonly object Gate = new();
private static readonly HashSet<int> LearnedNotCombat = new();
/// <summary>The essence's verdict now (see the class summary).</summary>
public static Verdict Judge(RynthCoreHost host, uint id)
{
if (host.HasGetObjectWcid && host.TryGetObjectWcid(id, out uint w) && w is >= 787801001 and <= 787801072)
return Verdict.Combat; // ACECustom combat essence block
if (host.HasGetObjectIntProperty)
{
if (host.TryGetObjectIntProperty(id, IntStructure, out _) || host.TryGetObjectIntProperty(id, IntMaxStructure, out _))
return Verdict.Combat;
if ((host.TryGetObjectIntProperty(id, IntUseRequiresSkill, out int s) && s == SkillSummoning)
|| (host.TryGetObjectIntProperty(id, IntUseRequiresSkillSpec, out int sp) && sp == SkillSummoning))
return Verdict.Combat;
if ((host.TryGetObjectIntProperty(id, IntBondLevel, out int bond) && bond > 0)
|| host.TryGetObjectIntProperty(id, IntPotencyStored, out _))
return Verdict.Combat;
}
if (host.HasGetObjectDataIdProperty && host.TryGetObjectDataIdProperty(id, DidIconUnderlay, out uint did)
&& (did & 0x00FFFFFF) == SummonGemUnderlay)
return Verdict.Combat;
// Nothing is concluded without the item's properties: an engine that can't read them, or
// an appraisal that hasn't landed.
if (!host.HasGetObjectIntProperty || !host.HasHasAppraisalData || !host.HasAppraisalData(id))
return Verdict.Unknown;
return Verdict.NotCombat;
}
/// <summary>Appraised, and none of a combat pet device's signs; or learned so this session.</summary>
public static bool IsNotCombat(RynthCoreHost host, uint id)
=> IsLearned(unchecked((int)id)) || Judge(host, id) == Verdict.NotCombat;
/// <summary>Records an essence that brought out a pet and is no combat pet device.</summary>
public static bool Learn(int id)
{
lock (Gate)
{
if (LearnedNotCombat.Count > 256) LearnedNotCombat.Clear();
return LearnedNotCombat.Add(id);
}
}
public static bool IsLearned(int id)
{
lock (Gate) return LearnedNotCombat.Contains(id);
}
/// <summary>Forgets what this session learned (a new PetManager, the tests).</summary>
public static void ResetSession()
{
lock (Gate) LearnedNotCombat.Clear();
}
}

View file

@ -56,6 +56,15 @@ namespace RynthCore.Plugin.RynthAi;
/// the server never confirmed is tried before it is parked, and an essence the client can no longer
/// name is not used.</item>
/// </list>
///
/// A pet that is none of the player's combat pets held the slot for good (2026-11-08,
/// R-20261108-194528-ab84: "combat pets are not autosummoning anymore", with a drudge the player
/// says they never chose standing beside them). Any "&lt;me&gt;'s ..." creature counted as the pet out, so a
/// passive (cosmetic) pet, which never despawns, stopped every summon with no log line. Now a pet
/// holds the slot only when it came from RynthAi's own summon, is named for an essence in the
/// Items list, or the server said it is active; any other pet is logged once and the chosen
/// essence is summoned anyway (ACE puts a passive pet away for a combat pet, and answers "is
/// already active" for a combat pet, which then holds the slot).
/// </summary>
internal sealed class PetManager
{
@ -151,6 +160,29 @@ internal sealed class PetManager
// not confirmed is tried with a summon before it is parked: an empty Use is refused harmlessly.
private readonly HashSet<int> _serverSaidEmpty = new();
// Which pet out holds the summon slot (2026-11-08, R-20261108-194528-ab84). Pets that came from
// our own summon or that the server called active; pets out when our last summon went (they are
// not its pet); until when a new pet counts as that summon's; pets out that hold nothing, each
// logged once.
private readonly HashSet<int> _slotPets = new();
private readonly HashSet<int> _petsOutAtSummon = new();
private long _claimNewPetsUntil;
private readonly HashSet<int> _otherPetsLogged = new();
// No combat pet device (R-20261108-215240-651b, PetDeviceKind): listed essences skipped, each
// logged once; essences not appraised yet, when we asked for their appraisal; the essence a
// summon just landed from, judged again until then; pets out of such an essence (they hold
// nothing).
private readonly HashSet<int> _notCombatLogged = new();
private readonly Dictionary<int, long> _appraisalAskedAt = new();
private int _landedDeviceId;
private long _landedCheckUntil;
private readonly HashSet<int> _passivePets = new();
/// <summary>A listed essence not appraised yet waits this long for its appraisal, once.</summary>
private const long AppraisalWaitMs = 3_000;
/// <summary>After a summon lands, its essence is judged again this long (its appraisal may still come).</summary>
private const long LandedCheckMs = 15_000;
private string _playerName = string.Empty;
private long _playerNameAt;
@ -187,6 +219,7 @@ internal sealed class PetManager
_objectCache = objectCache;
_combat = combat;
_skills = skills;
PetDeviceKind.ResetSession();
}
// ── Public API ─────────────────────────────────────────────────────────────
@ -209,6 +242,12 @@ internal sealed class PetManager
_summonElement = PetChoice.ElementOf(_host, unchecked((uint)_activeDeviceId),
_objectCache[_activeDeviceId]?.Name ?? "");
AssumePetFor(now, AssumeActiveAfterSummonMs);
// Judge the essence again now its pet is out: one used before its appraisal landed
// (it waits only AppraisalWaitMs) may turn out no combat pet device.
_landedDeviceId = _activeDeviceId;
_landedCheckUntil = now + LandedCheckMs;
if (PetDeviceKind.Judge(_host, unchecked((uint)_activeDeviceId)) == PetDeviceKind.Verdict.Unknown && _host.HasRequestId)
_host.RequestId(unchecked((uint)_activeDeviceId));
GoIdle();
}
}
@ -221,6 +260,7 @@ internal sealed class PetManager
GoIdle();
}
}
CheckLandedDevice(now);
// Timeout BEFORE the busy gate — busyCount can stick > 0 (a server-side
// decrement that never lands), and waiting on it would wedge the subsystem.
@ -271,6 +311,9 @@ internal sealed class PetManager
// The server has a pet: a silent one the ghost check passed over is real after all.
_ghostCheckOffUntil = NowMs + GhostCheckOffMs;
_petsLeftBehind.Clear();
// ACE says it only for a combat pet: whatever pet is out holds the slot, named for
// a listed essence or not (one summoned by hand from an unlisted essence).
foreach (var wo in OwnPetsInView()) _slotPets.Add(wo.Id);
_host.Log($"[RynthAi] Pet: the server says a pet is already active (essence 0x{(uint)_activeDeviceId:X8}); " +
$"pets the server has gone quiet about count as out for the next {GhostCheckOffMs / 60_000} min.");
AssumePetFor(NowMs, AssumeActiveAfterSummonMs);
@ -346,6 +389,8 @@ internal sealed class PetManager
_assumePetActiveUntil = 0;
_petSeenSinceSummon = false;
_ghostCheckOffUntil = 0;
_claimNewPetsUntil = 0;
_landedDeviceId = 0;
_lastThinkAt = 0;
var expired = new List<int>();
foreach (var kv in _deviceCooldownUntil)
@ -396,6 +441,23 @@ internal sealed class PetManager
// Only summon when mobs are near (the user's trigger).
if (!MonstersNearby()) return;
// A pet out that is none of the player's combat pets (R-20261108-194528-ab84: a drudge the
// player says they never chose) holds nothing: the chosen essence is summoned anyway. The ticked
// cosmetic pet is still dismissed first, which costs no essence cooldown.
if (OtherPetOut() is { } other)
{
if (YieldPetForCombat != null && YieldPetForCombat())
{
AssumePetFor(now, 3000);
return;
}
if (_otherPetsLogged.Count > 64) _otherPetsLogged.Clear();
if (_otherPetsLogged.Add(other.Id))
_host.Log($"[RynthAi] Pet: '{other.Name}' (0x{(uint)other.Id:X8}) is out, but it is none of your combat pets " +
"(not from RynthAi's summon, not named for a Pet essence in the Items list); summoning yours anyway " +
"(the server puts a passive pet away for it, or says a combat pet is already active).");
}
// Skill gate: must have Summoning trained to use any essence.
if (!IsSummoningTrained()) return;
@ -404,7 +466,7 @@ internal sealed class PetManager
// Best essence for the monster being fought first (Damage panel pet choice:
// a specific essence, an element, or Auto = lowest learned resist), then the
// rest in Items-panel order as fallbacks.
foreach (int deviceId in OrderDevicesForTarget(EnumeratePetDevices()))
foreach (int deviceId in OrderDevicesForTarget(CombatDevices(EnumeratePetDevices(), now)))
{
if (_deviceCooldownUntil.TryGetValue(deviceId, out long until) && now < until)
continue;
@ -492,6 +554,12 @@ internal sealed class PetManager
_actionIssuedAt = now;
// Server starts the PetDevice cooldown on Use, whether the pet spawns or not.
_deviceCooldownUntil[deviceId] = now + DeviceUseCooldownMs;
// A pet that shows up from now until the summon's answer and the assume window are over is
// this summon's, whatever it is named (a "Duo Summon Gem" pet is not named after its gem);
// the pets out now are not.
_petsOutAtSummon.Clear();
foreach (var wo in OwnPetsInView()) _petsOutAtSummon.Add(wo.Id);
_claimNewPetsUntil = now + ActionTimeoutMs + AssumeActiveAfterSummonMs;
RynthLog.Write(LogCat.Pets, $"[RynthAi] Pet: summoning from essence 0x{(uint)deviceId:X8} (charges={charges}); essence cooldown {DeviceUseCooldownMs / 1000}s.");
_host.UseFor(unchecked((uint)deviceId), "Pet", "summon a pet from the essence");
}
@ -657,10 +725,27 @@ internal sealed class PetManager
return _petOutCached ? _summonElement : null;
}
/// <summary>A live pet out that holds the summon slot (<see cref="HoldsSlot"/>).</summary>
private bool IsPetActive()
{
foreach (var wo in OwnPetsInView())
if (PetIsLive(wo) && HoldsSlot(wo)) return true;
return false;
}
/// <summary>A live pet out that holds nothing (none of the player's combat pets), or null.</summary>
private WorldObject? OtherPetOut()
{
foreach (var wo in OwnPetsInView())
if (PetIsLive(wo) && !HoldsSlot(wo)) return wo;
return null;
}
/// <summary>Every "&lt;me&gt;'s ..." creature in the landscape cache (corpses left out), live or not.</summary>
private IEnumerable<WorldObject> OwnPetsInView()
{
string me = PlayerName();
if (me.Length == 0) return false;
if (me.Length == 0) yield break;
string prefix = me + "'s ";
foreach (var wo in _objectCache.GetLandscape())
{
@ -670,9 +755,41 @@ internal sealed class PetManager
string n = wo.Name;
if (string.IsNullOrEmpty(n) || !n.StartsWith(prefix, StringComparison.Ordinal)) continue;
if (n.Contains("Corpse", StringComparison.OrdinalIgnoreCase)) continue;
if (!PetIsLive(wo)) continue;
yield return wo;
}
}
/// <summary>
/// The pet holds the summon slot: it came from our own summon (it showed up after the Use and
/// was not out before it), the server answered "is already active" while it was out, or it is
/// named for a Pet essence in the Items list. Anything else (a passive pet, one from an essence
/// the player never listed) holds nothing (2026-11-08, R-20261108-194528-ab84).
/// </summary>
private bool HoldsSlot(WorldObject pet)
{
if (_passivePets.Contains(pet.Id)) return false; // out of an essence that is no combat pet device
if (_slotPets.Contains(pet.Id)) return true;
if (NowMs < _claimNewPetsUntil && !_petsOutAtSummon.Contains(pet.Id))
{
if (_slotPets.Count > 64) _slotPets.Clear();
_slotPets.Add(pet.Id);
return true;
}
return NamedForListedEssence(pet.Name);
}
/// <summary>"&lt;me&gt;'s Fire Moar" for a listed "Fire Moar Essence (50)": the part before " Essence".</summary>
private bool NamedForListedEssence(string petName)
{
foreach (var rule in _settings.ConsumableRules)
{
if (!rule.Type.Equals("Pet", StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(rule.Name)) continue;
if (PetDeviceKind.IsNotCombat(_host, unchecked((uint)rule.Id))) continue; // a passive pet's essence names no combat pet
string n = rule.Name;
int i = n.IndexOf(" Essence", StringComparison.OrdinalIgnoreCase);
string b = (i > 0 ? n[..i] : n).Trim();
if (b.Length >= 3 && petName.Contains(b, StringComparison.OrdinalIgnoreCase)) return true;
}
return false;
}
@ -764,6 +881,74 @@ internal sealed class PetManager
}
}
/// <summary>
/// The listed essences that summon combat pets (2026-11-08, R-20261108-215240-651b: a listed
/// "Common Golem Essence" brought out a passive pet that held the slot ahead of the two combat
/// pets ticked). One that is no combat pet device (PetDeviceKind) is skipped, logged once. One
/// whose appraisal hasn't landed is asked for it and waits up to <see cref="AppraisalWaitMs"/>
/// once, then is used (a summon from it is judged again when it lands).
/// </summary>
private IEnumerable<int> CombatDevices(IEnumerable<int> ids, long now)
{
foreach (int id in ids)
{
uint uid = unchecked((uint)id);
var v = PetDeviceKind.IsLearned(id) ? PetDeviceKind.Verdict.NotCombat : PetDeviceKind.Judge(_host, uid);
if (v == PetDeviceKind.Verdict.NotCombat)
{
if (_notCombatLogged.Count > 64) _notCombatLogged.Clear();
if (_notCombatLogged.Add(id))
_host.Log($"[RynthAi] Pet: essence 0x{uid:X8} '{_objectCache[id]?.Name ?? "?"}' is no combat pet device " +
"(no charges, no Summoning requirement, no summoning-gem icon); the combat summoner skips it. " +
"A passive pet's essence shows under Cosmetic in the Mini Remote Pets tab.");
continue;
}
if (v == PetDeviceKind.Verdict.Unknown && _host.HasRequestId)
{
if (!_appraisalAskedAt.TryGetValue(id, out long asked))
{
if (_appraisalAskedAt.Count > 64) _appraisalAskedAt.Clear();
_appraisalAskedAt[id] = now;
_host.RequestId(uid);
continue;
}
if (now - asked < AppraisalWaitMs) continue;
}
yield return id;
}
}
/// <summary>
/// The essence a summon just landed from turns out no combat pet device (its appraisal came
/// after the Use): learned for the session, logged, and the pets it brought hold nothing, so
/// the player's combat pet is summoned now instead of after the passive pet (which never goes).
/// </summary>
private void CheckLandedDevice(long now)
{
if (_landedDeviceId == 0) return;
if (now >= _landedCheckUntil) { _landedDeviceId = 0; return; }
var v = PetDeviceKind.Judge(_host, unchecked((uint)_landedDeviceId));
if (v == PetDeviceKind.Verdict.Unknown) return;
int dev = _landedDeviceId;
_landedDeviceId = 0;
if (v == PetDeviceKind.Verdict.Combat) return;
PetDeviceKind.Learn(dev);
_notCombatLogged.Add(dev);
int pets = 0;
foreach (var wo in OwnPetsInView())
{
if (_petsOutAtSummon.Contains(wo.Id)) continue; // out before that summon: not its pet
_slotPets.Remove(wo.Id);
if (_passivePets.Count > 64) _passivePets.Clear();
if (_passivePets.Add(wo.Id)) pets++;
}
_claimNewPetsUntil = 0;
_assumePetActiveUntil = 0;
_host.Log($"[RynthAi] Pet: essence 0x{(uint)dev:X8} '{_objectCache[dev]?.Name ?? "?"}' brought out {pets} pet(s) but is no combat pet device " +
"(no charges, no Summoning requirement, no summoning-gem icon); not used for combat again this session, and its pet holds nothing.");
}
private int _lastChoiceTarget;
private string _lastChoiceReason = "";
@ -788,6 +973,18 @@ internal sealed class PetManager
if (_host.HasGetObjectWcid) _host.TryGetObjectWcid(unchecked((uint)target), out wcid);
string tname = _objectCache[target]?.Name ?? "";
string choice = wcid != 0 ? _combat.DamageStore?.GetManualPet(wcid) ?? "" : "";
// A Damage-panel pick ("I:<id>") is the Items entry's id. When that essence is gone and its
// same-named successor stands in (EnumeratePetDevices), the pick follows it by the entry's
// name; it read "picked essence not in pack, using Auto" and Auto could summon an essence the
// player had not picked for this monster (2026-11-08, R-20261108-194528-ab84 follow-up).
if (choice.StartsWith("I:", StringComparison.Ordinal) && int.TryParse(choice.AsSpan(2), out int pickId)
&& !raw.Exists(r => r.Id == pickId))
{
var picked = _settings.ConsumableRules.Find(r => r.Id == pickId && r.Type.Equals("Pet", StringComparison.OrdinalIgnoreCase));
int same = picked == null || string.IsNullOrWhiteSpace(picked.Name) ? -1
: raw.FindIndex(r => r.Name.Equals(picked.Name, StringComparison.OrdinalIgnoreCase));
if (same >= 0) choice = "I:" + raw[same].Id;
}
// Monsters-tab rule for this monster: its pet damage (PetDamage) wins over its
// weapon damage type. Same name match combat uses.

View file

@ -17,7 +17,11 @@ internal sealed record WeaponCandidate(int Id, string Name, int Kind, string Ele
/// <summary>What to fight a monster with: the weapon (0 = none), the element to cast or
/// debuff with, and why.</summary>
internal readonly record struct WeaponPlan(int WeaponId, string Element, string Source);
/// <param name="ForThisMonster">The player set this weapon for this monster: its own Damage tab
/// pick or Monsters rule weapon (step 1), or the wand of its Monsters rule's damage type (step 4).
/// Not a weakness, slayer or DEFAULT row pick. The swap tracker's window cap lets such a weapon in
/// for a new target (R-20261107-141028-b33e, WeaponSwapTracker).</param>
internal readonly record struct WeaponPlan(int WeaponId, string Element, string Source, bool ForThisMonster = false);
/// <summary>The kind of damage a character prefers to fight with (a Monsters rule's PreferredDamage).</summary>
internal enum DamageStyle { Auto, Melee, Missile, War, Void }
@ -168,7 +172,8 @@ internal static class WeaponPlanner
// this monster: a slayer of it beats that one (step 3).
if (fixedPick != null && !fixedIsDefault)
return FixedPlan(fixedPick, Slays(fixedPick, creatureType)
? fixedSource + ", " + SlayerSource(creatureType, fixedPick.SlayerBonus) : fixedSource, rule, weak, canCast);
? fixedSource + ", " + SlayerSource(creatureType, fixedPick.SlayerBonus) : fixedSource, rule, weak, canCast)
with { ForThisMonster = true };
if (listed.Count == 0)
{
@ -219,7 +224,7 @@ internal static class WeaponPlanner
if (ruleSet)
{
var w = BestOf(pool, rule, null) ?? (styled ? null : BestOf(listed, rule, null));
if (w != null) return new WeaponPlan(w.Id, rule, "Monsters rule " + rule);
if (w != null) return new WeaponPlan(w.Id, rule, "Monsters rule " + rule, ForThisMonster: true);
var keep = InHand(pool) ?? pool[0];
// A wand casts its own element: the rule's element only when the weapon has none.
string keepElem = WandElement(keep, canCast) ?? rule;

View file

@ -19,7 +19,12 @@ namespace RynthCore.Plugin.RynthAi;
/// Lightning Quadrelle for a Giant Maggot, then the next target, a Grub weak to Bludgeon,
/// was fought with the Quadrelle for 5-10 s until the 20 s dwell from the last swap ran out
/// - "he attacks for about 5 seconds with the wrong element weapon"). The window cap still
/// bounds a fight that alternates between two kinds of monster.
/// bounds a fight that alternates between two kinds of monster, except for a weapon the
/// player set for the new target (<c>forThisMonster</c>: its Damage tab pick, its Monsters
/// rule's weapon or damage type), which goes in at once (2026-11-08, R-20261107-141028-b33e,
/// Conquest: four swaps among wasps and other kinds, then the Fire Staff meant for an Oaken
/// Guardian the player had selected was kept out with "4 swaps in 60s" and the Guardian was
/// fought with the Frost Sceptre until it died, about 18 s later). Its swap still counts toward the cap for others.
/// * A swap counts as landed when its weapon reaches the hand, even if the choice moved on
/// while it was in flight.
/// * A 'too busy' answer (<see cref="Busy"/>) is not a try: the server never looked at the
@ -118,8 +123,11 @@ internal sealed class WeaponSwapTracker
/// What to do about <paramref name="chosenId"/> with <paramref name="inHandId"/> in hand
/// (0 = nothing readable in hand). <paramref name="forKey"/> is the fight the weapon is
/// chosen for (the target id; 0 = unknown, treated as the same fight as the last swap).
/// <paramref name="forThisMonster"/>: the player set <paramref name="chosenId"/> for that
/// target (WeaponPlan.ForThisMonster); for a new target the window cap doesn't hold it.
/// </summary>
public Step Next(int chosenId, int inHandId, DateTime now, Func<int, string>? nameOf = null, int forKey = 0)
public Step Next(int chosenId, int inHandId, DateTime now, Func<int, string>? nameOf = null, int forKey = 0,
bool forThisMonster = false)
{
HoldReason = "";
_askKey = forKey;
@ -165,7 +173,11 @@ internal sealed class WeaponSwapTracker
return Step.Hold;
}
_landed.RemoveAll(t => (now - t).TotalMilliseconds > SwapWindowMs);
if (_landed.Count >= MaxSwapsPerWindow)
// The player's own weapon for a new target isn't a choice going back and forth: the
// cap counted the swaps for the other kinds and kept it out (R-20261107-141028-b33e).
// The same target (or no key) is still capped.
bool newTargetsOwnPick = forThisMonster && forKey != 0 && forKey != _lastKey;
if (_landed.Count >= MaxSwapsPerWindow && !newTargetsOwnPick)
{
HoldReason = $"{_landed.Count} swaps in {SwapWindowMs / 1000:0}s";
return Step.Hold;

View file

@ -129,6 +129,11 @@ internal sealed class LegacyWeaponsUi
}
string? type = PackConsumableType(wo);
if (type == null || _settings.ConsumableRules.Any(x => x.Id == wo.Id)) continue;
// An "...Essence" that is no combat pet device (appraised: no charges, no Summoning
// requirement, no summoning-gem icon; PetDeviceKind) is not listed as a combat pet: a
// listed "Common Golem Essence" summoned a passive pet that held the slot
// (2026-11-08, R-20261108-215240-651b). One not appraised yet is still listed, as before.
if (type == "Pet" && PetDeviceKind.IsNotCombat(_host, unchecked((uint)wo.Id))) continue;
_settings.ConsumableRules.Add(new ConsumableRule { Id = wo.Id, Name = wo.Name, Type = type });
consumables++;
}

View file

@ -9,6 +9,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using RynthCore.Loot;
using RynthCore.Plugin.Shared;
using RynthCore.PluginSdk;
namespace RynthCore.Plugin.RynthAi.MiniRemote;
@ -119,7 +120,14 @@ internal sealed class MiniRemoteInventory
// ── Actions ─────────────────────────────────────────────────────────────
public bool Use(WorldObject wo) => _host.HasUseObject && _host.UseObject(unchecked((uint)wo.Id));
/// <summary>
/// Uses the item through UseFor, so the log names the feature and the reason
/// ("[Use] RynthAi/Pets ... - keep the cosmetic pet out"). It was a bare UseObject: a pet the
/// Pets tab summoned (cosmetic, heal pet, the Summon button) left only the engine's "[Use]
/// engine:" line, and nothing told it from a combat summon (2026-11-08, R-20261108-194528-ab84).
/// </summary>
public bool Use(WorldObject wo, string why, UseKind kind = UseKind.Auto)
=> _host.HasUseObject && _host.UseFor(unchecked((uint)wo.Id), "Pets", why, kind);
/// <summary>Forgets cached WCIDs / appraisal throttles (logout).</summary>
public void Reset()

View file

@ -190,12 +190,28 @@ internal sealed class PetsTab
}
assigned = false;
if (NameIs(wo, S.HealPetName)) return PetKind.Healing;
if (IsPassiveEssence(wo)) return PetKind.Cosmetic;
if (!IsPetDevice(wo)) return null;
if (LooksLikeHealPet(wo.Name)) return PetKind.Healing;
if (LooksLikeCosmeticPet(wo.Name)) return PetKind.Cosmetic;
return PetKind.Combat;
}
/// <summary>
/// An essence that summons a passive pet: the combat summoner learned it this session (its pet
/// came out and it is no combat pet device), or it is in the combat list and its appraisal
/// shows no combat pet device (PetDeviceKind). It is shown under Cosmetic, not ticked as a
/// combat pet (2026-11-08, R-20261108-215240-651b: a "Common Golem Essence" listed as a combat
/// pet by the pack fill, which the Pets tab didn't show at all: no charges, so no pet device).
/// An appraised item that is not listed stays as before (an "... Essence" trade item is no pet).
/// </summary>
private bool IsPassiveEssence(WorldObject wo)
{
if (PetDeviceKind.IsLearned(wo.Id)) return true;
if (!PetRules().Any(r => r.Id == wo.Id || r.Name.Equals(wo.Name, StringComparison.OrdinalIgnoreCase))) return false;
return PetDeviceKind.Judge(_ctx.Host, unchecked((uint)wo.Id)) == PetDeviceKind.Verdict.NotCombat;
}
private static bool NameIs(WorldObject wo, string name)
=> !string.IsNullOrWhiteSpace(name) && wo.Name.Equals(name.Trim(), StringComparison.OrdinalIgnoreCase);
@ -233,7 +249,7 @@ internal sealed class PetsTab
var essence = FindCarried(S.CosmeticPetName);
if (pet == null || essence == null) return false;
if (!PetMatchesEssence(pet, essence) && _cosmeticOutEssenceId != essence.Id) return false;
if (_ctx.Inventory.IsBusy || !_ctx.Inventory.Use(essence)) return false;
if (_ctx.Inventory.IsBusy || !_ctx.Inventory.Use(essence, "dismiss the cosmetic pet so a combat pet can be summoned")) return false;
long now = MiniRemoteContext.NowMs;
_cosmeticOutEssenceId = 0;
@ -341,7 +357,7 @@ internal sealed class PetsTab
var essence = FindHealEssence();
if (essence == null) { _healStatus = "no heal-pet essence found"; return; }
if (_ctx.Inventory.Uses(essence) == 0 && !AllowSummonOnEmpty()) { _healStatus = "heal-pet essence is empty"; return; }
if (!_ctx.Inventory.Use(essence)) return;
if (!_ctx.Inventory.Use(essence, $"summon the heal pet (HP {pct}%)")) return;
_healEssenceId = essence.Id;
_lastSummonEssenceId = essence.Id;
_healStartedAt = now;
@ -379,7 +395,7 @@ internal sealed class PetsTab
{
var cache = _ctx.Inventory.Cache;
var essence = cache?[_healEssenceId];
if (essence != null) _ctx.Inventory.Use(essence);
if (essence != null) _ctx.Inventory.Use(essence, "dismiss the heal pet");
}
// ── Active pet ──────────────────────────────────────────────────────────
@ -458,7 +474,7 @@ internal sealed class PetsTab
_cosmeticNextAt = now + 30_000;
return;
}
if (!_ctx.Inventory.Use(essence)) return;
if (!_ctx.Inventory.Use(essence, "keep the cosmetic pet out")) return;
_cosmeticOutEssenceId = essence.Id;
_lastSummonEssenceId = essence.Id;
// Covers the summon round-trip so the pet isn't re-summoned before it appears.
@ -479,7 +495,7 @@ internal sealed class PetsTab
WorldObject? essence = essenceId != 0 ? _ctx.Inventory.Items().FirstOrDefault(w => w.Id == essenceId) : ChosenEssence(kind);
if (essence == null) { _ctx.Chat($"[Mini Remote] No {KindNames[(int)kind].ToLowerInvariant()} pet selected."); return; }
if (_ctx.Inventory.Uses(essence) == 0 && !AllowSummonOnEmpty()) { _ctx.Chat($"[Mini Remote] {essence.Name} has no uses left."); return; }
if (!_ctx.Inventory.Use(essence)) return;
if (!_ctx.Inventory.Use(essence, "Summon (Mini Remote Pets tab)", UseKind.Asked)) return;
_lastSummonEssenceId = essence.Id;
if (NameIs(essence, S.CosmeticPetName)) _cosmeticOutEssenceId = essence.Id;
@ -494,7 +510,7 @@ internal sealed class PetsTab
if (_ctx.Inventory.IsBusy) { _ctx.Chat("[Mini Remote] Busy — try again in a moment."); return; }
var essence = ResolveActiveEssence(pet);
if (essence == null) { _ctx.Chat($"[Mini Remote] Couldn't find the essence for {pet.Name}."); return; }
if (!_ctx.Inventory.Use(essence)) return;
if (!_ctx.Inventory.Use(essence, "Despawn (Mini Remote Pets tab)", UseKind.Asked)) return;
// A manual dismiss shouldn't be undone straight away by "Keep cosmetic pet out".
_cosmeticNextAt = MiniRemoteContext.NowMs + Math.Max(5, S.CosmeticRespawnSeconds) * 1000L;
@ -516,7 +532,7 @@ internal sealed class PetsTab
foreach (var r in rules)
{
var wo = _ctx.Inventory.Items().FirstOrDefault(w => w.Id == r.Id || NameIs(w, r.Name));
if (wo != null) return wo;
if (wo != null && !IsPassiveEssence(wo)) return wo; // a listed passive pet is no combat pick
}
return null;
}