Skip to content

Commit

Permalink
Added attack speed to character stats packet
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Sep 26, 2024
1 parent f93e5b6 commit 63c06b9
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The characters enters the game world.
| Index | Length | Data Type | Value | Description |
|-------|--------|-----------|-------|-------------|
| 0 | 1 | Byte | 0xC3 | [Packet type](PacketTypes.md) |
| 1 | 1 | Byte | 84 | Packet header - length of the packet |
| 1 | 1 | Byte | 96 | Packet header - length of the packet |
| 2 | 1 | Byte | 0xF3 | Packet header - packet type identifier |
| 3 | 1 | Byte | 0x03 | Packet header - sub packet type identifier |
| 4 | 1 | Byte | | X |
Expand Down Expand Up @@ -42,7 +42,10 @@ The characters enters the game world.
| 76 | 2 | ShortLittleEndian | | MaxFruitPoints |
| 78 | 2 | ShortLittleEndian | | UsedNegativeFruitPoints |
| 80 | 2 | ShortLittleEndian | | MaxNegativeFruitPoints |
| 81 | 1 | Byte | | InventoryExtensions |
| 82 | 2 | ShortLittleEndian | | AttackSpeed |
| 84 | 2 | ShortLittleEndian | | MagicSpeed |
| 86 | 2 | ShortLittleEndian | | MaximumAttackSpeed |
| 88 | 1 | Byte | | InventoryExtensions |

### CharacterHeroState Enum

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ await connection.SendCharacterInformationExtendedAsync(
this._player.SelectedCharacter.GetMaximumFruitPoints(),
(ushort)this._player.SelectedCharacter.UsedNegFruitPoints,
this._player.SelectedCharacter.GetMaximumFruitPoints(),
(ushort)this._player.Attributes[Stats.AttackSpeed],
(ushort)this._player.Attributes[Stats.AttackSpeed], // todo: implement MagicSpeed
200, // todo: This is the maximum attack speed, make configurable.
(byte)this._player.SelectedCharacter.InventoryExtensions)
.ConfigureAwait(false);

Expand Down
8 changes: 7 additions & 1 deletion src/Network/Packets/ServerToClient/ConnectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3051,12 +3051,15 @@ int WritePacket()
/// <param name="maxFruitPoints">The max fruit points.</param>
/// <param name="usedNegativeFruitPoints">The used negative fruit points.</param>
/// <param name="maxNegativeFruitPoints">The max negative fruit points.</param>
/// <param name="attackSpeed">The attack speed.</param>
/// <param name="magicSpeed">The magic speed.</param>
/// <param name="maximumAttackSpeed">The maximum attack speed.</param>
/// <param name="inventoryExtensions">The inventory extensions.</param>
/// <remarks>
/// Is sent by the server when: After the character was selected by the player and entered the game.
/// Causes reaction on client side: The characters enters the game world.
/// </remarks>
public static async ValueTask SendCharacterInformationExtendedAsync(this IConnection? connection, byte @x, byte @y, ushort @mapId, ulong @currentExperience, ulong @experienceForNextLevel, ushort @levelUpPoints, ushort @strength, ushort @agility, ushort @vitality, ushort @energy, ushort @leadership, uint @currentHealth, uint @maximumHealth, uint @currentMana, uint @maximumMana, uint @currentShield, uint @maximumShield, uint @currentAbility, uint @maximumAbility, uint @money, CharacterHeroState @heroState, CharacterStatus @status, ushort @usedFruitPoints, ushort @maxFruitPoints, ushort @usedNegativeFruitPoints, ushort @maxNegativeFruitPoints, byte @inventoryExtensions)
public static async ValueTask SendCharacterInformationExtendedAsync(this IConnection? connection, byte @x, byte @y, ushort @mapId, ulong @currentExperience, ulong @experienceForNextLevel, ushort @levelUpPoints, ushort @strength, ushort @agility, ushort @vitality, ushort @energy, ushort @leadership, uint @currentHealth, uint @maximumHealth, uint @currentMana, uint @maximumMana, uint @currentShield, uint @maximumShield, uint @currentAbility, uint @maximumAbility, uint @money, CharacterHeroState @heroState, CharacterStatus @status, ushort @usedFruitPoints, ushort @maxFruitPoints, ushort @usedNegativeFruitPoints, ushort @maxNegativeFruitPoints, ushort @attackSpeed, ushort @magicSpeed, ushort @maximumAttackSpeed, byte @inventoryExtensions)
{
if (connection is null)
{
Expand Down Expand Up @@ -3093,6 +3096,9 @@ int WritePacket()
packet.MaxFruitPoints = @maxFruitPoints;
packet.UsedNegativeFruitPoints = @usedNegativeFruitPoints;
packet.MaxNegativeFruitPoints = @maxNegativeFruitPoints;
packet.AttackSpeed = @attackSpeed;
packet.MagicSpeed = @magicSpeed;
packet.MaximumAttackSpeed = @maximumAttackSpeed;
packet.InventoryExtensions = @inventoryExtensions;

return packet.Header.Length;
Expand Down
33 changes: 30 additions & 3 deletions src/Network/Packets/ServerToClient/ServerToClientPackets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15295,7 +15295,7 @@ private CharacterInformationExtended(Memory<byte> data, bool initialize)
/// <summary>
/// Gets the initial length of this data packet. When the size is dynamic, this value may be bigger than actually needed.
/// </summary>
public static int Length => 84;
public static int Length => 96;

/// <summary>
/// Gets the header of this packet.
Expand Down Expand Up @@ -15536,13 +15536,40 @@ public ushort MaxNegativeFruitPoints
set => WriteUInt16LittleEndian(this._data.Span[80..], value);
}

/// <summary>
/// Gets or sets the attack speed.
/// </summary>
public ushort AttackSpeed
{
get => ReadUInt16LittleEndian(this._data.Span[82..]);
set => WriteUInt16LittleEndian(this._data.Span[82..], value);
}

/// <summary>
/// Gets or sets the magic speed.
/// </summary>
public ushort MagicSpeed
{
get => ReadUInt16LittleEndian(this._data.Span[84..]);
set => WriteUInt16LittleEndian(this._data.Span[84..], value);
}

/// <summary>
/// Gets or sets the maximum attack speed.
/// </summary>
public ushort MaximumAttackSpeed
{
get => ReadUInt16LittleEndian(this._data.Span[86..]);
set => WriteUInt16LittleEndian(this._data.Span[86..], value);
}

/// <summary>
/// Gets or sets the inventory extensions.
/// </summary>
public byte InventoryExtensions
{
get => this._data.Span[81];
set => this._data.Span[81] = value;
get => this._data.Span[88];
set => this._data.Span[88] = value;
}

/// <summary>
Expand Down
19 changes: 17 additions & 2 deletions src/Network/Packets/ServerToClient/ServerToClientPackets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5479,7 +5479,7 @@
<Code>F3</Code>
<SubCode>03</SubCode>
<Name>CharacterInformationExtended</Name>
<Length>84</Length>
<Length>96</Length>
<Direction>ServerToClient</Direction>
<SentWhen>After the character was selected by the player and entered the game.</SentWhen>
<CausedReaction>The characters enters the game world.</CausedReaction>
Expand Down Expand Up @@ -5617,7 +5617,22 @@
<Name>MaxNegativeFruitPoints</Name>
</Field>
<Field>
<Index>81</Index>
<Index>82</Index>
<Type>ShortLittleEndian</Type>
<Name>AttackSpeed</Name>
</Field>
<Field>
<Index>84</Index>
<Type>ShortLittleEndian</Type>
<Name>MagicSpeed</Name>
</Field>
<Field>
<Index>86</Index>
<Type>ShortLittleEndian</Type>
<Name>MaximumAttackSpeed</Name>
</Field>
<Field>
<Index>88</Index>
<Type>Byte</Type>
<Name>InventoryExtensions</Name>
</Field>
Expand Down
33 changes: 30 additions & 3 deletions src/Network/Packets/ServerToClient/ServerToClientPacketsRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14571,7 +14571,7 @@ private CharacterInformationExtendedRef(Span<byte> data, bool initialize)
/// <summary>
/// Gets the initial length of this data packet. When the size is dynamic, this value may be bigger than actually needed.
/// </summary>
public static int Length => 84;
public static int Length => 96;

/// <summary>
/// Gets the header of this packet.
Expand Down Expand Up @@ -14812,13 +14812,40 @@ public ushort MaxNegativeFruitPoints
set => WriteUInt16LittleEndian(this._data[80..], value);
}

/// <summary>
/// Gets or sets the attack speed.
/// </summary>
public ushort AttackSpeed
{
get => ReadUInt16LittleEndian(this._data[82..]);
set => WriteUInt16LittleEndian(this._data[82..], value);
}

/// <summary>
/// Gets or sets the magic speed.
/// </summary>
public ushort MagicSpeed
{
get => ReadUInt16LittleEndian(this._data[84..]);
set => WriteUInt16LittleEndian(this._data[84..], value);
}

/// <summary>
/// Gets or sets the maximum attack speed.
/// </summary>
public ushort MaximumAttackSpeed
{
get => ReadUInt16LittleEndian(this._data[86..]);
set => WriteUInt16LittleEndian(this._data[86..], value);
}

/// <summary>
/// Gets or sets the inventory extensions.
/// </summary>
public byte InventoryExtensions
{
get => this._data[81];
set => this._data[81] = value;
get => this._data[88];
set => this._data[88] = value;
}

/// <summary>
Expand Down

0 comments on commit 63c06b9

Please sign in to comment.