Sequence primary weapon replacement through the server-confirmed AutoWield transaction: return the occupied weapon to the player pack, wait for its move event, then wield the requested item. Route authoritative CombatMode property updates so peace stays peace and war adopts the new weapon stance without client-synthesized animation. Co-Authored-By: Codex <codex@openai.com>
47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using AcDream.Core.Combat;
|
|
|
|
namespace AcDream.Core.Net;
|
|
|
|
/// <summary>
|
|
/// Routes the local player's server-owned combat-mode quality into
|
|
/// <see cref="CombatState"/>. Retail
|
|
/// <c>ClientCombatSystem::OnQualityChanged @ 0x0056C1B0</c> reads
|
|
/// PropertyInt 40 and calls <c>SetCombatMode</c> on every change.
|
|
/// </summary>
|
|
public static class CombatStateWiring
|
|
{
|
|
public const uint CombatModePropertyId = 40u;
|
|
|
|
public static void Wire(WorldSession session, CombatState combat)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(session);
|
|
ArgumentNullException.ThrowIfNull(combat);
|
|
|
|
session.PlayerIntPropertyUpdated += update =>
|
|
ApplyPlayerIntProperty(combat, update.Property, update.Value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Pure event adapter exposed for conformance tests. Composite or unknown
|
|
/// values are ignored: retail's quality contains one concrete mode.
|
|
/// </summary>
|
|
public static bool ApplyPlayerIntProperty(
|
|
CombatState combat,
|
|
uint property,
|
|
int value)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(combat);
|
|
if (property != CombatModePropertyId)
|
|
return false;
|
|
|
|
CombatMode mode = (CombatMode)value;
|
|
if (mode is not (CombatMode.NonCombat
|
|
or CombatMode.Melee
|
|
or CombatMode.Missile
|
|
or CombatMode.Magic))
|
|
return false;
|
|
|
|
combat.SetCombatMode(mode);
|
|
return true;
|
|
}
|
|
}
|