RynthSuite as of 2026-11-08 (internal c9af5266): release 2026.11.8.2
This commit is contained in:
parent
f8fa62b64c
commit
81de36a2e5
12 changed files with 764 additions and 26 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
92
Plugins/RynthCore.Plugin.RynthAi/Combat/PetDeviceKind.cs
Normal file
92
Plugins/RynthCore.Plugin.RynthAi/Combat/PetDeviceKind.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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 "<me>'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 "<me>'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>"<me>'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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ internal static class Program
|
|||
InstallPathsTests.Register(runner);
|
||||
PetRefillTests.Register(runner);
|
||||
PetSummonStopsTests.Register(runner);
|
||||
PetSelectionTests.Register(runner);
|
||||
AutoStackTests.Register(runner);
|
||||
AutoVendorSplitTests.Register(runner);
|
||||
AutoVendorZeroRateTests.Register(runner);
|
||||
|
|
|
|||
284
Tools/RynthCore.RynthAiHostTests/Tests/PetSelectionTests.cs
Normal file
284
Tools/RynthCore.RynthAiHostTests/Tests/PetSelectionTests.cs
Normal file
|
|
@ -0,0 +1,284 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.CreatureData;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// The player's pet choice (2026-11-08, R-20261108-194528-ab84: "combat pets are not autosummoning
|
||||
// anymore", a drudge the player never chose standing next to them):
|
||||
// * any "<me>'s ..." creature counted as the pet out, so a pet that is none of the player's combat
|
||||
// pets (a passive pet never despawns) held every summon for good, with no log line;
|
||||
// * a Damage-panel pick of an essence that was replaced by a same-named one fell back to Auto,
|
||||
// which could summon an essence the player had not picked for that monster.
|
||||
internal static class PetSelectionTests
|
||||
{
|
||||
private const uint Player = 0x50000D21;
|
||||
private const uint Mob = 0x80320010;
|
||||
private const uint MobWcid = 41001;
|
||||
private const uint Essence = 0x80320001; // Fire Moar Essence (listed)
|
||||
private const uint Essence2 = 0x80320002; // its same-named successor
|
||||
private const uint Frost = 0x80320003; // Frost Moar Essence (listed first)
|
||||
private const uint Other = 0x80320020; // a pet out that is none of the player's
|
||||
private const uint Ours = 0x80320021; // the pet our summon brings
|
||||
private const uint StructureKey = 92; // AcIntProperty.Structure
|
||||
private const uint Lb = 0xA9B40000;
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("pet choice: a pet out that is none of your combat pets does not hold summons; yours is summoned, logged once (before: never)", OtherPetDoesNotHold);
|
||||
r.Add("pet choice: the other pet turns out a combat pet ('is already active'): it holds the slot, no Use every 45 s", OtherPetAlreadyActive);
|
||||
r.Add("pet choice: a pet from our own summon holds the slot whatever it is named (a summon gem's pet)", OwnSummonHoldsWhateverItsName);
|
||||
r.Add("pet choice: a Damage-panel pick follows its replaced essence by name, not Auto's other essence (before: Auto)", PickFollowsReplacedEssence);
|
||||
// R-20261108-215240-651b (2026.11.8.1): a listed "Common Golem Essence" (a passive pet: no
|
||||
// charges, no Summoning requirement) was summoned ahead of the two combat pets ticked, and
|
||||
// its pet, from our own summon, held the slot for good.
|
||||
r.Add("pet choice: a listed essence that is no combat pet device (appraised) is never summoned; the combat pet is (before: the golem)", PassiveEssenceSkipped);
|
||||
r.Add("pet choice: an essence used before its appraisal that turns out passive is learned, and its pet holds nothing (before: held for good)", PassiveLearnedAfterSummon);
|
||||
r.Add("pet choice: the Pets tab shows a listed passive essence under Cosmetic, unticked, and the combat pick skips it", PetsTabShowsPassiveAsCosmetic);
|
||||
r.Add("pet choice: pack fill does not list an appraised passive essence as a Pet; a combat essence and an unappraised one still are", FillSkipsPassiveEssence);
|
||||
}
|
||||
|
||||
private const uint Golem = 0x80320030; // Common Golem Essence: a passive pet's essence
|
||||
private const uint Living = 0x80320031; // Living Weapon Essence: a combat essence
|
||||
private const uint GolemPet = 0x80320032;
|
||||
private const uint UseRequiresSkillKey = 366;
|
||||
|
||||
/// <summary>A rig whose Items list is the golem first, then the combat essence (the pack fill's name order).</summary>
|
||||
private static Rig PassiveRig(bool golemAppraised, bool listLiving = true)
|
||||
{
|
||||
var rig = new Rig(essenceName: "Living Weapon Essence");
|
||||
rig.S.ConsumableRules.Clear();
|
||||
FakeHost.Names.Remove(Essence);
|
||||
FakeHost.Containers.Remove(Essence);
|
||||
// The golem: appraised (or not yet), with no charge count and no Summoning requirement.
|
||||
FakeHost.Names[Golem] = "Common Golem Essence";
|
||||
FakeHost.Containers[Golem] = Player;
|
||||
if (golemAppraised) FakeHost.Appraised.Add(Golem);
|
||||
FakeHost.Names[Living] = "Living Weapon Essence";
|
||||
FakeHost.Containers[Living] = Player;
|
||||
FakeHost.Ints[(Living, StructureKey)] = 40;
|
||||
FakeHost.Ints[(Living, UseRequiresSkillKey)] = 54;
|
||||
FakeHost.Appraised.Add(Living);
|
||||
_ = rig.Cache[unchecked((int)Golem)]; // filed in the pack
|
||||
_ = rig.Cache[unchecked((int)Living)];
|
||||
rig.S.ConsumableRules.Add(new ConsumableRule { Id = unchecked((int)Golem), Name = "Common Golem Essence", Type = "Pet" });
|
||||
if (listLiving) ListLiving(rig);
|
||||
return rig;
|
||||
}
|
||||
|
||||
private static void ListLiving(Rig rig)
|
||||
=> rig.S.ConsumableRules.Add(new ConsumableRule { Id = unchecked((int)Living), Name = "Living Weapon Essence", Type = "Pet" });
|
||||
|
||||
private static void PassiveEssenceSkipped()
|
||||
{
|
||||
using var rig = PassiveRig(golemAppraised: true);
|
||||
rig.Run(1_500);
|
||||
Check.Eq(Rig.UsesOf(Golem), 0, "the passive pet's essence is not summoned (before: it was, first in the list)");
|
||||
Check.Eq(Rig.UsesOf(Living), 1, "the ticked combat pet is");
|
||||
Check.True(Logged("is no combat pet device") && Logged("0x80320030"), "the skipped essence is logged with its id");
|
||||
rig.Run(60_000);
|
||||
Check.Eq(Rig.UsesOf(Golem), 0, "still never");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("is no combat pet device")), 1, "logged once");
|
||||
}
|
||||
|
||||
private static void PassiveLearnedAfterSummon()
|
||||
{
|
||||
using var rig = PassiveRig(golemAppraised: false, listLiving: false);
|
||||
rig.Run(1_500);
|
||||
Check.True(FakeHost.IdRequests.Contains(Golem), "the unappraised essence is asked for its appraisal first");
|
||||
Check.Eq(Rig.UsesOf(Golem), 0, "and waits for it a moment");
|
||||
rig.Run(3_000);
|
||||
Check.Eq(Rig.UsesOf(Golem), 1, "no appraisal came: it is used, as before");
|
||||
rig.ShowPet(GolemPet, "Pet Tester's Common Pet Golem");
|
||||
rig.Run(1_000);
|
||||
FakeHost.Appraised.Add(Golem); // the appraisal lands: no charges, no Summoning requirement
|
||||
rig.Run(1_000);
|
||||
Check.True(Logged("brought out 1 pet(s) but is no combat pet device"), "learned and logged");
|
||||
ListLiving(rig); // the player's combat pet
|
||||
rig.Run(1_500);
|
||||
Check.Eq(Rig.UsesOf(Living), 1, "the golem holds nothing: the combat pet is summoned beside it (before: never while it stood)");
|
||||
rig.Run(60_000);
|
||||
Check.Eq(Rig.UsesOf(Golem), 1, "the golem's essence is not used again this session");
|
||||
}
|
||||
|
||||
private static void PetsTabShowsPassiveAsCosmetic()
|
||||
{
|
||||
using var rig = PassiveRig(golemAppraised: true);
|
||||
var host = FakeHost.Create(Player);
|
||||
string dir = System.IO.Path.Combine(Program.TempRoot, "pet-selection-petstab");
|
||||
if (System.IO.Directory.Exists(dir)) System.IO.Directory.Delete(dir, recursive: true);
|
||||
System.IO.Directory.CreateDirectory(dir);
|
||||
var store = new RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteStore(dir);
|
||||
var cache = rig.Cache;
|
||||
var ctx = new RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteContext(host, store.Load(), store,
|
||||
new RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteInventory(host, () => cache),
|
||||
new RynthCore.Plugin.RynthAi.MiniRemote.ServerHubClient(host), () => rig.S);
|
||||
var tab = new RynthCore.Plugin.RynthAi.MiniRemote.PetsTab(ctx);
|
||||
const System.Reflection.BindingFlags Any = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic;
|
||||
typeof(RynthCore.Plugin.RynthAi.MiniRemote.PetsTab).GetMethod("RebuildPetSnapshot", Any)!.Invoke(tab, new object[] { false });
|
||||
var pets = (RynthCore.Plugin.RynthAi.MiniRemote.PetStats[])typeof(RynthCore.Plugin.RynthAi.MiniRemote.PetsTab).GetField("_pets", Any)!.GetValue(tab)!;
|
||||
var golem = pets.FirstOrDefault(p => p.Id == unchecked((int)Golem));
|
||||
Check.True(golem != null, "the golem's essence is in the roster (before: not shown at all, no charges)");
|
||||
Check.Eq(golem?.Kind, RynthCore.Plugin.RynthAi.MiniRemote.PetKind.Cosmetic, "under Cosmetic");
|
||||
Check.False(golem?.Selected ?? true, "not ticked (the cosmetic pick is empty)");
|
||||
var living = pets.FirstOrDefault(p => p.Id == unchecked((int)Living));
|
||||
Check.Eq(living?.Kind, RynthCore.Plugin.RynthAi.MiniRemote.PetKind.Combat, "the combat essence stays Combat");
|
||||
typeof(RynthCore.Plugin.RynthAi.MiniRemote.PetsTab).GetMethod("UpdateHudPetLine", Any)!.Invoke(tab, new object?[] { null });
|
||||
Check.Eq(tab.HudPetName, "Living Weapon Essence", "the Mini Remote's next combat pet skips the golem");
|
||||
}
|
||||
|
||||
private static void FillSkipsPassiveEssence()
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.WeaponCalls = true; // HasAppraisalData
|
||||
var host = FakeHost.Create(Player);
|
||||
FakeHost.Appraised.Add(Golem); // appraised: no charges, no Summoning requirement
|
||||
FakeHost.Ints[(Living, StructureKey)] = 40; // a combat essence: a charge count
|
||||
const uint Unread = 0x80320033; // not appraised yet: listed as before
|
||||
var s = new LegacyUiSettings();
|
||||
var ui = new LegacyWeaponsUi(s, host);
|
||||
var inv = new List<WorldObject>
|
||||
{
|
||||
new(unchecked((int)Golem), "Common Golem Essence", AcObjectClass.Misc),
|
||||
new(unchecked((int)Living), "Living Weapon Essence", AcObjectClass.Misc),
|
||||
new(unchecked((int)Unread), "Dark Shaman Essence", AcObjectClass.Misc),
|
||||
};
|
||||
ui.FillFromPack(inv, Player);
|
||||
var pets = s.ConsumableRules.Where(r => r.Type == "Pet").Select(r => r.Name).ToList();
|
||||
Check.False(pets.Contains("Common Golem Essence"), "the passive essence is not listed as a combat pet (before: it was)");
|
||||
Check.True(pets.Contains("Living Weapon Essence"), "the combat essence is");
|
||||
Check.True(pets.Contains("Dark Shaman Essence"), "an essence not appraised yet still is (no verdict without its properties)");
|
||||
}
|
||||
|
||||
private sealed class Rig : IDisposable
|
||||
{
|
||||
public long Now = 2_000_000;
|
||||
public readonly LegacyUiSettings S = new() { SummonPets = true, MonsterRange = 20, CustomPetRange = 5 };
|
||||
public readonly PetManager Pets;
|
||||
public readonly WorldObjectCache Cache;
|
||||
public readonly MonsterDamageStore Store = new();
|
||||
|
||||
public Rig(string essenceName = "Fire Moar Essence (50)", string? otherPet = null, bool frostFirst = false, bool successor = false)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.WeaponCalls = true; // UseObject (summon)
|
||||
Place(Player, "Pet Tester", 96, 96, creature: false);
|
||||
FakeHost.PlayerPose = (Lb | 0x1C, 96f, 96f, 0f);
|
||||
Place(Mob, "Practice Dummy", 96, 99, creature: true); // 3 m north; no creature-type weakness
|
||||
FakeHost.Wcids[Mob] = MobWcid;
|
||||
var known = new List<uint> { Mob };
|
||||
Carry(Essence, essenceName, known);
|
||||
if (successor) Carry(Essence2, essenceName, known);
|
||||
if (frostFirst)
|
||||
{
|
||||
Carry(Frost, "Frost Moar Essence (50)", known);
|
||||
S.ConsumableRules.Add(new ConsumableRule { Id = unchecked((int)Frost), Name = "Frost Moar Essence (50)", Type = "Pet" });
|
||||
}
|
||||
S.ConsumableRules.Add(new ConsumableRule { Id = unchecked((int)Essence), Name = essenceName, Type = "Pet" });
|
||||
|
||||
var host = FakeHost.Create(Player);
|
||||
Cache = FakeHost.MakeCache(host, Player, known);
|
||||
S.IsMacroRunning = true;
|
||||
var combat = new CombatManager(host, S, Cache);
|
||||
combat.SetPlayerId(Player);
|
||||
combat.SetDamageStores(null, Store);
|
||||
combat.ScanNearbyTargets();
|
||||
Check.True(combat.ScannedTargets.Count == 1, "rig: the monster is scanned");
|
||||
if (otherPet != null) ShowPet(Other, otherPet);
|
||||
PetManager.Clock = () => Now;
|
||||
Pets = new PetManager(host, S, Cache, combat, null);
|
||||
}
|
||||
|
||||
private static void Carry(uint id, string name, List<uint> known)
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
FakeHost.Containers[id] = Player;
|
||||
FakeHost.Ints[(id, StructureKey)] = 50;
|
||||
known.Add(id);
|
||||
}
|
||||
|
||||
public void ShowPet(uint id, string name)
|
||||
{
|
||||
Place(id, name, 96, 97, creature: true);
|
||||
_ = Cache[unchecked((int)id)]; // filed on the landscape as a creature
|
||||
Check.True(Cache.GetLandscape().Any(w => w.Id == unchecked((int)id)), "rig: the pet is in the landscape cache");
|
||||
}
|
||||
|
||||
private static void Place(uint id, string name, float x, float y, bool creature)
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
FakeHost.Positions[id] = (Lb | 0x1C, x, y, 0f);
|
||||
if (creature) FakeHost.ItemTypes[id] = 0x10;
|
||||
}
|
||||
|
||||
public void Run(long ms)
|
||||
{
|
||||
for (long t = 0; t < ms; t += 100)
|
||||
{
|
||||
Now += 100;
|
||||
Pets.OnHeartbeat(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static int UsesOf(uint id) => FakeHost.Uses.Count(u => u == id);
|
||||
|
||||
public void Dispose() => PetManager.Clock = static () => Environment.TickCount64;
|
||||
}
|
||||
|
||||
private static bool Logged(string text) => FakeHost.Logs.Any(l => l.Contains(text, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private static void OtherPetDoesNotHold()
|
||||
{
|
||||
using var rig = new Rig(otherPet: "Pet Tester's Common Pet Drudge");
|
||||
rig.Run(1_500);
|
||||
Check.Eq(Rig.UsesOf(Essence), 1, "the drudge is none of the player's combat pets: the listed essence is summoned (before: never)");
|
||||
Check.True(Logged("none of your combat pets") && Logged("0x80320020"), "the other pet is logged with its id");
|
||||
|
||||
// The server puts the passive pet away and the combat pet comes.
|
||||
FakeHost.Names.Remove(Other);
|
||||
FakeHost.Positions.Remove(Other);
|
||||
rig.ShowPet(Ours, "Pet Tester's Fire Moar");
|
||||
rig.Run(3 * 60_000);
|
||||
Check.Eq(Rig.UsesOf(Essence), 1, "the player's own pet is out: no second summon");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("none of your combat pets")), 1, "logged once");
|
||||
}
|
||||
|
||||
private static void OtherPetAlreadyActive()
|
||||
{
|
||||
using var rig = new Rig(otherPet: "Pet Tester's Acid Maiden"); // summoned by hand from an unlisted essence
|
||||
rig.Run(1_500);
|
||||
Check.Eq(Rig.UsesOf(Essence), 1, "a pet not from the list: one summon is tried");
|
||||
rig.Pets.OnChatWindowText("Pet Tester's Acid Maiden is already active");
|
||||
rig.Run(4 * 60_000);
|
||||
Check.Eq(Rig.UsesOf(Essence), 1, "the server says it is a combat pet: it holds the slot, no Use every 45 s");
|
||||
}
|
||||
|
||||
private static void OwnSummonHoldsWhateverItsName()
|
||||
{
|
||||
using var rig = new Rig(essenceName: "Duo Summon Gem");
|
||||
rig.Run(1_500);
|
||||
Check.Eq(Rig.UsesOf(Essence), 1, "no pet out: summon");
|
||||
rig.ShowPet(Ours, "Pet Tester's Olthoi Hunter"); // not named after the gem
|
||||
rig.Run(3 * 60_000);
|
||||
Check.Eq(Rig.UsesOf(Essence), 1, "the pet our summon brought holds the slot: no second summon");
|
||||
Check.False(Logged("none of your combat pets"), "and it is not called someone else's pet");
|
||||
}
|
||||
|
||||
private static void PickFollowsReplacedEssence()
|
||||
{
|
||||
using var rig = new Rig(frostFirst: true, successor: true);
|
||||
rig.Store.SetManualPet(MobWcid, "I:" + unchecked((int)Essence)); // the player picked Fire Moar for this monster
|
||||
FakeHost.Names.Remove(Essence); // gone (a death corpse); a same-named one is in the pack
|
||||
FakeHost.Containers.Remove(Essence);
|
||||
rig.Run(1_500);
|
||||
Check.Eq(Rig.UsesOf(Frost), 0, "the essence Auto would take first is not used (before: Frost Moar, 'picked essence not in pack')");
|
||||
Check.Eq(Rig.UsesOf(Essence2), 1, "the pick's same-named successor is summoned");
|
||||
Check.True(Logged("picked Fire Moar Essence"), "the choice line names the pick");
|
||||
}
|
||||
}
|
||||
|
|
@ -61,6 +61,7 @@ internal static class WeaponTests
|
|||
r.Add("weapon swap: one in flight, confirmed, retry cap, then what's in hand", SwapOneInFlight);
|
||||
r.Add("weapon swap: no flip-flop between two weapons", SwapNoFlipFlop);
|
||||
r.Add("weapon swap: a new target that wants the weapon just swapped away from gets it at once (Drakkon 2026-10-12)", SwapBackForNewTarget);
|
||||
r.Add("weapon swap: the weapon set for a monster goes in past the 4-swaps-a-minute cap for a new target (R-20261107-141028-b33e)", PerMobWandPastWindowCap);
|
||||
r.Add("weapon swap: a server refusal counts as a failed try", SwapRefused);
|
||||
r.Add("weapon swap: 'too busy' is no try, and a portal or recall ends the rest (Kelpie 2026-10-15)", SwapBusyNotCounted);
|
||||
r.Add("weapon swap: combat reads ACE's busy answer (0x1D then SaveFailed 0) as busy, a real refusal as a try", CombatReadsBusyWield);
|
||||
|
|
@ -1165,6 +1166,103 @@ internal static class WeaponTests
|
|||
Check.Eq(tr2.Next(next, hand, u.AddSeconds(5), forKey: 0x8010), WeaponSwapTracker.Step.Hold, "a fifth swap inside a minute: held");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// R-20261107-141028-b33e (Conquest, 2026-11-07): a mage fought wasps, wisps and gromnies with
|
||||
/// four wands; four swaps landed inside a minute, then the player selected an Oaken Guardian and
|
||||
/// its Fire Staff was kept out ("keeping Frost Sceptre instead of Fire Staff (4 swaps in 60s)").
|
||||
/// The Guardian died to Cold. A weapon the player set for the monster (here its Monsters rule's
|
||||
/// weapon) now goes in for a new target past the window cap; a weakness pick, and the same target,
|
||||
/// are still capped.
|
||||
/// </summary>
|
||||
private static void PerMobWandPastWindowCap()
|
||||
{
|
||||
const int OtherA = 0x7101, OtherB = 0x7102, OtherC = 0x7103, OtherD = 0x7104;
|
||||
DateTime now = new(2026, 11, 7, 15, 9, 31);
|
||||
try
|
||||
{
|
||||
RynthClock.TestNow = () => now;
|
||||
|
||||
// Four swaps for other targets in the last minute, ending with `second` in hand.
|
||||
void FillWindow(WeaponSwapTracker tr, int first, int second, int lastKey)
|
||||
{
|
||||
int hand = second;
|
||||
int[] keys = { OtherA, OtherB, OtherC, lastKey };
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
DateTime at = now.AddSeconds(-40 + i * 10);
|
||||
int want = hand == first ? second : first;
|
||||
tr.Next(want, hand, at, forKey: keys[i]);
|
||||
tr.Sent(want, hand, at);
|
||||
tr.Next(want, want, at.AddSeconds(1), forKey: keys[i]); // landed
|
||||
hand = want;
|
||||
}
|
||||
}
|
||||
var equip = typeof(CombatManager).GetMethod("EquipWeaponAndSetStance", BindingFlags.Instance | BindingFlags.NonPublic)!;
|
||||
|
||||
// The Monsters rule's weapon for this monster, a new target: wielded at once.
|
||||
var rig = new Rig(1535, "Ethereal Wisp");
|
||||
rig.S.ItemRules.Add(new() { Id = unchecked((int)FireWand), Name = "Fire Wand", Element = "Fire", ElementSource = "icon" });
|
||||
rig.S.EnsureDefaultRule();
|
||||
var own = new MonsterRule { Name = "Ethereal", WeaponId = unchecked((int)FireWand) };
|
||||
rig.S.MonsterRules.Add(own);
|
||||
rig.C.InHandOverride = () => unchecked((int)ListedWand);
|
||||
rig.C.activeTargetId = rig.Target.Id;
|
||||
FillWindow(rig.C.SwapTracker, unchecked((int)FireWand), unchecked((int)ListedWand), OtherD);
|
||||
Check.True(rig.C.PlanFor(rig.Target, own).ForThisMonster, "the rule's weapon is the monster's own pick");
|
||||
equip.Invoke(rig.C, new object[] { rig.Target, "Auto" });
|
||||
Check.Eq(FakeHost.Uses.FirstOrDefault(), FireWand,
|
||||
"four swaps in the minute, a new target: its rule's fire wand is wielded, not held: "
|
||||
+ string.Join(" | ", FakeHost.Logs.Where(l => l.Contains("EquipDiag")).Take(4)));
|
||||
|
||||
// The weakness's pick for a new target: still capped, and the hold says what wanted it.
|
||||
var weak = new Rig(1535, "Ethereal Wisp");
|
||||
weak.S.ItemRules.Add(new() { Id = unchecked((int)FireWand), Name = "Fire Wand", Element = "Fire", ElementSource = "icon" });
|
||||
weak.S.EnsureDefaultRule();
|
||||
weak.C.InHandOverride = () => unchecked((int)FireWand);
|
||||
weak.C.activeTargetId = weak.Target.Id;
|
||||
FillWindow(weak.C.SwapTracker, unchecked((int)ListedWand), unchecked((int)FireWand), OtherD);
|
||||
var wp = weak.C.PlanFor(weak.Target, null);
|
||||
Check.Eq(unchecked((uint)wp.WeaponId), ListedWand, "the weakness picks the Lightning wand");
|
||||
Check.False(wp.ForThisMonster, "a weakness pick isn't the monster's own");
|
||||
equip.Invoke(weak.C, new object[] { weak.Target, "Auto" });
|
||||
Check.Eq(FakeHost.Uses.Count, 0, "a weakness swap past four in a minute: held");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("(4 swaps in 60s; wanted for: weak to Lightning")),
|
||||
"the hold names what wanted the swap: " + string.Join(" | ", FakeHost.Logs.Where(l => l.Contains("keeping")).Take(3)));
|
||||
|
||||
// The same target as the last swap: the cap still holds the monster's own pick.
|
||||
var tr = new WeaponSwapTracker();
|
||||
const int Hand = 1, Own = 2, Third = 3, Guardian = 0x7200;
|
||||
FillWindow(tr, Third, Hand, Guardian);
|
||||
Check.Eq(tr.Next(Own, Hand, now, forKey: Guardian, forThisMonster: true), WeaponSwapTracker.Step.Hold,
|
||||
"the target the last swap was for: capped");
|
||||
Check.Eq(tr.Next(Own, Hand, now, forKey: 0, forThisMonster: true), WeaponSwapTracker.Step.Hold, "no target known: capped");
|
||||
Check.Eq(tr.Next(Own, Hand, now, forKey: 0x7201, forThisMonster: true), WeaponSwapTracker.Step.Swap, "a new target: its own pick goes");
|
||||
Check.Eq(tr.Next(Own, Hand, now, forKey: 0x7201), WeaponSwapTracker.Step.Hold, "the same swap not set for it: capped");
|
||||
|
||||
// Which plans are the monster's own: its Damage tab pick, its rule's weapon or damage
|
||||
// type; not the Default row's damage type or weapon, nor the weakness.
|
||||
var p = new Rig(1535, "Ethereal Wisp");
|
||||
p.S.ItemRules.Add(new() { Id = unchecked((int)FireWand), Name = "Fire Wand", Element = "Fire", ElementSource = "icon" });
|
||||
p.S.EnsureDefaultRule();
|
||||
var defRow = p.S.MonsterRules[0];
|
||||
Check.True(p.C.PlanFor(p.Target, new MonsterRule { Name = "Ethereal", DamageType = "Fire" }).ForThisMonster, "the rule's damage type");
|
||||
defRow.DamageType = "Fire";
|
||||
var dp = p.C.PlanFor(p.Target, defRow);
|
||||
Check.Eq(unchecked((uint)dp.WeaponId), FireWand, "the Default row's damage type picks the fire wand");
|
||||
Check.False(dp.ForThisMonster, "but that is every monster's, not this one's");
|
||||
defRow.DamageType = "Auto";
|
||||
p.Store.SetManualWeapon(1535, FireWand);
|
||||
Check.True(p.C.PlanFor(p.Target, new MonsterRule { Name = "Ethereal" }).ForThisMonster, "this monster's Damage tab pick");
|
||||
p.Store.SetManualWeapon(1535, 0);
|
||||
p.Store.SetDefaultWeapon(FireWand);
|
||||
Check.False(p.C.PlanFor(p.Target, new MonsterRule { Name = "Ethereal" }).ForThisMonster, "the Damage tab DEFAULT row's weapon");
|
||||
}
|
||||
finally
|
||||
{
|
||||
RynthClock.TestNow = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kelpie 2026-10-14 11:41:06-08: Fire -> Piercing sent, the target changed and the plan
|
||||
/// wanted Fire again while Piercing reached the hand. The landing must count, so the swap
|
||||
|
|
|
|||
Loading…
Reference in a new issue