diff --git a/src/RynthCore.Engine/Compatibility/AutoIdDrain.cs b/src/RynthCore.Engine/Compatibility/AutoIdDrain.cs
index 313b201..9ca8b8d 100644
--- a/src/RynthCore.Engine/Compatibility/AutoIdDrain.cs
+++ b/src/RynthCore.Engine/Compatibility/AutoIdDrain.cs
@@ -22,8 +22,8 @@
// looked into, and a sweep that overflowed the pending list counts as not done: it runs
// again once there is room.
//
-// Combat: Inventory sends wait while a target is selected or a cast or attack
-// is in flight (Context.CombatBusy). Each 0xC8 raises AC's busy count, and plugins gate
+// Combat: Inventory sends wait while a cast or attack is in flight
+// (Context.CombatBusy, AutoIdPolicy.InCombat; a selected target alone does not count). Each 0xC8 raises AC's busy count, and plugins gate
// their casts on it. The selected target and an open container are not held.
//
// Bounds: _incoming is capped at MaxIncoming (oldest dropped, counted) because the drain
@@ -78,7 +78,7 @@ internal sealed class AutoIdDrain
public long OpenedAtMs; // when OpenContainer was opened (0 = unknown)
public long SettleUntilMs; // PlayerLifecycleLog.SettleUntilMs
public long LoginCompleteAtMs; // LoginLifecycleHooks.LoginCompleteAtMs
- public bool CombatBusy; // a target selected, or a cast or attack in flight (Inventory waits)
+ public bool CombatBusy; // a cast or attack in flight, AutoIdPolicy.InCombat (Inventory waits)
}
private struct Pending
diff --git a/src/RynthCore.Engine/Compatibility/AutoIdPolicy.cs b/src/RynthCore.Engine/Compatibility/AutoIdPolicy.cs
index a07e0b1..dbf8cc1 100644
--- a/src/RynthCore.Engine/Compatibility/AutoIdPolicy.cs
+++ b/src/RynthCore.Engine/Compatibility/AutoIdPolicy.cs
@@ -27,8 +27,8 @@
// a client crashed in AC's CreateObject handling during the
// login create burst). A container the player opened after the last
// transition ended is not deferred. Inventory sends are capped at 5 a
-// second and wait while a target is selected or a cast or attack is in
-// flight. Creatures, ground items, other players: never.
+// second and wait while a cast or attack is in flight (a selected
+// target alone does not hold them). Creatures, ground items, other players: never.
// Off nothing, the selected target included.
// Plugins calling the host RequestId are not limited by any of this.
//
@@ -98,7 +98,7 @@ internal static class AutoIdPolicy
WaitRate,
/// Place unknown and the object snapshot still empty: keep it (up to UnknownMaxWaitMs).
WaitSnapshot,
- /// Inventory while in combat (a target selected, a cast or an attack in flight): keep it.
+ /// Inventory while in combat (a cast or an attack in flight, InCombat): keep it.
WaitCombat,
}
@@ -113,8 +113,7 @@ internal static class AutoIdPolicy
/// : Inventory only, the send rate allows one now ().
/// : Unknown only, the object snapshot has been filled (an
/// object missing from a warm snapshot is not coming; one missing from a cold one may be).
- /// : Inventory only, a target is selected or a cast or attack is in
- /// flight. Each 0xC8 raises AC's busy count, which plugins gate casts on, so the pack waits.
+ /// : Inventory only, a cast or attack is in flight (). Each 0xC8 raises AC's busy count, which plugins gate casts on, so the pack waits.
///
public static Verdict Decide(AutoIdMode mode, Class cls, long ageMs, bool inDefer, bool openedAfterSettle,
bool fresh, bool cached, bool inventoryRateOk = true, bool snapshotWarm = true,
@@ -161,6 +160,15 @@ internal static class AutoIdPolicy
}
}
+ ///
+ /// In combat for the Inventory hold: a cast in flight (, CastGate) or an
+ /// attack running. A selected target alone is NOT combat ( is taken
+ /// only so the tests can show that): a hunting bot nearly always has something selected, and the
+ /// pack (mana stones included) would never be appraised.
+ ///
+ public static bool InCombat(uint selectedTarget, int castBusy, bool attacking) =>
+ castBusy != 0 || attacking;
+
///
/// When the last transition ended: the later of the settle window's end
/// (WorldTransitionState.SettleUntilMs, 0 = none yet; it only moves on a death, a portal,
diff --git a/src/RynthCore.Engine/Compatibility/AutoIdService.cs b/src/RynthCore.Engine/Compatibility/AutoIdService.cs
index 9fc9a98..37b1492 100644
--- a/src/RynthCore.Engine/Compatibility/AutoIdService.cs
+++ b/src/RynthCore.Engine/Compatibility/AutoIdService.cs
@@ -313,9 +313,9 @@ internal static class AutoIdService
SettleUntilMs = PlayerLifecycleLog.SettleUntilMs,
LoginCompleteAtMs = LoginLifecycleHooks.LoginCompleteAtMs,
// Each 0xC8 raises AC's busy count, which plugins gate their casts on: the
- // pack waits while a target is selected, a cast is in flight or an attack runs.
- CombatBusy = target != 0 || CastGate.GetCastBusyState() != 0
- || (ClientActionGates.TryReadAttacking(out bool attacking) && attacking),
+ // pack waits while a cast is in flight or an attack runs (not for a selection alone).
+ CombatBusy = AutoIdPolicy.InCombat(target, CastGate.GetCastBusyState(),
+ ClientActionGates.TryReadAttacking(out bool attacking) && attacking),
};
_drain.Tick(ctx, sent);
@@ -436,7 +436,7 @@ internal static class AutoIdService
{
AutoIdMode.All => "all (every created object, the old behaviour)",
AutoIdMode.Off => "off (no background appraisals, not even the selected target)",
- _ => $"limited (selected target; open container and own inventory after {AutoIdPolicy.MinAgeMs / 1000} s, {AutoIdPolicy.DeferMs / 1000} s after login or a portal/death/teleport; inventory at most {1000 / AutoIdPolicy.InventoryMinIntervalMs}/s, and not while a target is selected or a cast or attack is in flight)",
+ _ => $"limited (selected target; open container and own inventory after {AutoIdPolicy.MinAgeMs / 1000} s, {AutoIdPolicy.DeferMs / 1000} s after login or a portal/death/teleport; inventory at most {1000 / AutoIdPolicy.InventoryMinIntervalMs}/s, and not while a cast or attack is in flight)",
};
string extra = "";
if (_drain.Overflow > 0) extra += $", overflow {_drain.Overflow}";
diff --git a/tools/EngineRobustnessTests/AutoIdDrainTests.cs b/tools/EngineRobustnessTests/AutoIdDrainTests.cs
index 193bcae..9b74a64 100644
--- a/tools/EngineRobustnessTests/AutoIdDrainTests.cs
+++ b/tools/EngineRobustnessTests/AutoIdDrainTests.cs
@@ -240,7 +240,7 @@ internal static partial class Program
Check(f.PendingCount == AutoIdDrain.MaxIncoming, $"the newest {AutoIdDrain.MaxIncoming} kept, got {f.PendingCount}");
}
- // The pack waits through combat (target selected, cast or attack in flight); kept, not
+ // The pack waits through combat (a cast or attack in flight); kept, not
// dropped; an open container is not held.
private static void DrainCombatHoldsInventory()
{
diff --git a/tools/EngineRobustnessTests/AutoIdLimitTests.cs b/tools/EngineRobustnessTests/AutoIdLimitTests.cs
index 82dbf3d..a6cc47b 100644
--- a/tools/EngineRobustnessTests/AutoIdLimitTests.cs
+++ b/tools/EngineRobustnessTests/AutoIdLimitTests.cs
@@ -110,6 +110,14 @@ internal static partial class Program
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Target, 0, false, false, false, false, combatBusy: true) == V.Send, "combat never holds the selected target");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Container, Old, false, true, false, false, combatBusy: true) == V.Send, "combat never holds an open container");
Check(AutoIdPolicy.Decide(AutoIdMode.All, C.Inventory, Old, false, false, false, false, combatBusy: true) == V.Send, "All mode: no combat hold (old behaviour)");
+ // What counts as combat: a cast or an attack, never a selection alone (a hunting bot
+ // nearly always has one, and the pack would never be appraised).
+ Check(!AutoIdPolicy.InCombat(0x80001234, 0, false), "target selected, no cast, no attack: not combat");
+ bool selectedOnly = AutoIdPolicy.InCombat(0x80001234, 0, false);
+ Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Inventory, Old, false, false, false, false, combatBusy: selectedOnly) == V.Send, "target selected, no cast, no attack: the pack sends");
+ Check(AutoIdPolicy.InCombat(0, 1, false), "a cast in flight is combat");
+ Check(AutoIdPolicy.InCombat(0, 0, true), "an attack running is combat");
+ Check(!AutoIdPolicy.InCombat(0, 0, false), "nothing at all: not combat");
// Limited: unknown place.
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Unknown, 100, false, false, false, false) == V.WaitAge, "unknown place waits while young");
Check(AutoIdPolicy.Decide(AutoIdMode.Limited, C.Unknown, Old, false, false, false, false) == V.SkipMode, "still unknown when old: skipped");