AutoId: a selected target alone no longer holds the pack
A hunting bot nearly always has something selected, so holding Inventory appraisals on a selection would leave the pack (mana stones included) unread. Combat is now a cast in flight (CastGate) or an attack running (ClientActionGates) only, in the pure AutoIdPolicy.InCombat, which takes the selection as input and ignores it. Tests: target selected with no cast and no attack is not combat and the pack sends; a cast, or an attack, alone is combat. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8668f2a3ca
commit
831001796b
5 changed files with 29 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
/// <summary>Place unknown and the object snapshot still empty: keep it (up to UnknownMaxWaitMs).</summary>
|
||||
WaitSnapshot,
|
||||
/// <summary>Inventory while in combat (a target selected, a cast or an attack in flight): keep it.</summary>
|
||||
/// <summary>Inventory while in combat (a cast or an attack in flight, InCombat): keep it.</summary>
|
||||
WaitCombat,
|
||||
}
|
||||
|
||||
|
|
@ -113,8 +113,7 @@ internal static class AutoIdPolicy
|
|||
/// <paramref name="inventoryRateOk"/>: Inventory only, the send rate allows one now (<see cref="InventoryRateAllows"/>).
|
||||
/// <paramref name="snapshotWarm"/>: 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).
|
||||
/// <paramref name="combatBusy"/>: 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.
|
||||
/// <paramref name="combatBusy"/>: Inventory only, a cast or attack is in flight (<see cref="InCombat"/>). Each 0xC8 raises AC's busy count, which plugins gate casts on, so the pack waits.
|
||||
/// </summary>
|
||||
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
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In combat for the Inventory hold: a cast in flight (<paramref name="castBusy"/>, CastGate) or an
|
||||
/// attack running. A selected target alone is NOT combat (<paramref name="selectedTarget"/> 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.
|
||||
/// </summary>
|
||||
public static bool InCombat(uint selectedTarget, int castBusy, bool attacking) =>
|
||||
castBusy != 0 || attacking;
|
||||
|
||||
/// <summary>
|
||||
/// 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,
|
||||
|
|
|
|||
|
|
@ -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}";
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue