~ruther/NosSmooth

cfd1fd7bf38e6996ce54a6e145b31212819e07a7 — Rutherther 3 years ago 398f20a
feat(packets): add entities and maps packets
19 files changed, 392 insertions(+), 23 deletions(-)

A Packets/NosSmooth.Packets/Enums/PortalType.cs
A Packets/NosSmooth.Packets/Server/Battle/BsPacket.cs
A Packets/NosSmooth.Packets/Server/Battle/SuPacket.cs
A Packets/NosSmooth.Packets/Server/Entities/CondPacket.cs
A Packets/NosSmooth.Packets/Server/Entities/EqPacket.cs
M Packets/NosSmooth.Packets/Server/Entities/StPacket.cs
A Packets/NosSmooth.Packets/Server/Maps/AtPacket.cs
M Packets/NosSmooth.Packets/Server/Maps/CMapPacket.cs
A Packets/NosSmooth.Packets/Server/Maps/DropPacket.cs
R Packets/NosSmooth.Packets/Server/{Entities/InEquipmentSubPacket.cs => Maps/InEquipmentSubPacket.cs}
R Packets/NosSmooth.Packets/Server/{Entities/InItemSubPacket.cs => Maps/InItemSubPacket.cs}
R Packets/NosSmooth.Packets/Server/{Entities/InNonPlayerSubPacket.cs => Maps/InNonPlayerSubPacket.cs}
R Packets/NosSmooth.Packets/Server/{Entities/InPacket.cs => Maps/InPacket.cs}
R Packets/NosSmooth.Packets/Server/{Entities/InPlayerSubPacket.cs => Maps/InPlayerSubPacket.cs}
A Packets/NosSmooth.Packets/Server/Maps/OutPacket.cs
A Packets/NosSmooth.Packets/Server/Portals/GpPacket.cs
M Packets/NosSmooth.Packets/Server/Skills/SkiPacket.cs
M Packets/NosSmooth.Packets/Server/Skills/SkiSubPacket.cs
M Packets/NosSmooth.Packets/Server/Skills/SrPacket.cs
A Packets/NosSmooth.Packets/Enums/PortalType.cs => Packets/NosSmooth.Packets/Enums/PortalType.cs +31 -0
@@ 0,0 1,31 @@
//
//  PortalType.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;

#pragma warning disable CS1591
namespace NosSmooth.Packets.Enums;

[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600", MessageId = "Elements should be documented", Justification = "Should be self-explanatory.")]
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602", MessageId = "Enumeration items should be documented", Justification = "Should be self-explanatory.")]
public enum PortalType
{
    MapPortal = -1,
    TsNormal = 0, // same over >127 - sbyte
    Closed = 1,
    Open = 2,
    Miniland = 3,
    TsEnd = 4,
    TsEndClosed = 5,
    Exit = 6,
    ExitClosed = 7,
    Raid = 8,
    Effect = 9, // same as 13 - 19 and 20 - 126
    BlueRaid = 10,
    DarkRaid = 11,
    TimeSpace = 12,
    ShopTeleport = 20
}
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Battle/BsPacket.cs => Packets/NosSmooth.Packets/Server/Battle/BsPacket.cs +63 -0
@@ 0,0 1,63 @@
//
//  BsPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.Packets.Enums;
using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Battle;

/// <summary>
/// An AoE skill used packet.
/// </summary>
/// <param name="CasterEntityType">The caster entity type.</param>
/// <param name="CasterEntityId">The caster entity id.</param>
/// <param name="X">The x coordinate of the skill.</param>
/// <param name="Y"></param>
/// <param name="Cooldown"></param>
/// <param name="AttackAnimationId"></param>
/// <param name="EffectId"></param>
/// <param name="Unknown1"></param>
/// <param name="Unknown2"></param>
/// <param name="Unknown3"></param>
/// <param name="Unknown4"></param>
/// <param name="Unknown5"></param>
/// <param name="Unknown6"></param>
/// <param name="Unknown7"></param>
[PacketHeader("bs", PacketSource.Server)]
[GenerateSerializer(true)]
public record BsPacket
(
    [PacketIndex(0)]
    EntityType CasterEntityType,
    [PacketIndex(1)]
    long CasterEntityId,
    [PacketIndex(2)]
    short X,
    [PacketIndex(3)]
    short Y,
    [PacketIndex(4)]
    int SkillVNum,
    [PacketIndex(5)]
    short Cooldown,
    [PacketIndex(6)]
    long AttackAnimationId,
    [PacketIndex(7)]
    long EffectId,
    [PacketIndex(8)]
    int Unknown1,
    [PacketIndex(9)]
    int Unknown2,
    [PacketIndex(10)]
    int Unknown3,
    [PacketIndex(11)]
    int Unknown4,
    [PacketIndex(12)]
    int Unknown5,
    [PacketIndex(13)]
    int Unknown6,
    [PacketIndex(14)]
    int Unknown7
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Battle/SuPacket.cs => Packets/NosSmooth.Packets/Server/Battle/SuPacket.cs +64 -0
@@ 0,0 1,64 @@
//
//  SuPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.Packets.Enums;
using NosSmooth.Packets.Enums.Battle;
using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Battle;

/// <summary>
/// Represents skill used.
/// </summary>
/// <param name="CasterEntityType">The type of the caster entity.</param>
/// <param name="CasterEntityId">The entity id of the caster.</param>
/// <param name="TargetEntityType">The type of the target entity.</param>
/// <param name="TargetEntityId">The entity id of the target.</param>
/// <param name="SkillVNum">The VNum of the used skill.</param>
/// <param name="SkillCooldown">The cooldown of the skill.</param>
/// <param name="AttackAnimation">The number of the attack animation.</param>
/// <param name="SkillEffect">The number of the skill effect.</param>
/// <param name="PositionX">The x position where the skill target is.</param>
/// <param name="PositionY">The y position where the skill target is.</param>
/// <param name="TargetIsAlive">Whether the target of the skill is alive.</param>
/// <param name="Damage">The damage the entity has taken.</param>
/// <param name="HitMode">The hit mode.</param>
/// <param name="SkillTypeMinusOne">The skill type of the skill.</param>
[PacketHeader("su", PacketSource.Server)]
[GenerateSerializer(true)]
public record SuPacket
(
    [PacketIndex(0)]
    EntityType CasterEntityType,
    [PacketIndex(1)]
    long CasterEntityId,
    [PacketIndex(2)]
    EntityType TargetEntityType,
    [PacketIndex(3)]
    long TargetEntityId,
    [PacketIndex(4)]
    int SkillVNum,
    [PacketIndex(5)]
    long SkillCooldown,
    [PacketIndex(6)]
    long AttackAnimation,
    [PacketIndex(7)]
    long SkillEffect,
    [PacketIndex(8)]
    long PositionX,
    [PacketIndex(9)]
    long PositionY,
    [PacketIndex(10)]
    bool TargetIsAlive,
    [PacketIndex(11)]
    byte HpPercentage,
    [PacketIndex(12)]
    uint Damage,
    [PacketIndex(13)]
    HitMode? HitMode,
    [PacketIndex(14)]
    int SkillTypeMinusOne
) : IPacket;

A Packets/NosSmooth.Packets/Server/Entities/CondPacket.cs => Packets/NosSmooth.Packets/Server/Entities/CondPacket.cs +34 -0
@@ 0,0 1,34 @@
//
//  CondPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.Packets.Enums;
using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Entities;

/// <summary>
/// Cond packet is sent when the player is moving or when attacking an entity.
/// </summary>
/// <param name="EntityType">The type of the entity.</param>
/// <param name="EntityId">The id of the entity.</param>
/// <param name="CantAttack">Whether the entity cant attack.</param>
/// <param name="CantMove">Whether the entity cant move.</param>
/// <param name="Speed">The speed of the entity.</param>
[PacketHeader("cond", PacketSource.Server)]
[GenerateSerializer(true)]
public record CondPacket
(
    [PacketIndex(0)]
    EntityType EntityType,
    [PacketIndex(1)]
    long EntityId,
    [PacketIndex(2)]
    bool CantAttack,
    [PacketIndex(3)]
    bool CantMove,
    [PacketIndex(4)]
    int Speed
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Entities/EqPacket.cs => Packets/NosSmooth.Packets/Server/Entities/EqPacket.cs +52 -0
@@ 0,0 1,52 @@
//
//  EqPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.Packets.Enums;
using NosSmooth.Packets.Enums.Players;
using NosSmooth.Packets.Server.Maps;
using NosSmooth.Packets.Server.Weapons;
using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Entities;

/// <summary>
/// Player
/// </summary>
/// <param name="CharacterId"></param>
/// <param name="AuthorityType"></param>
/// <param name="Sex"></param>
/// <param name="HairStyle"></param>
/// <param name="HairColor"></param>
/// <param name="Class"></param>
/// <param name="EquipmentSubPacket"></param>
/// <param name="WeaponUpgradeRareSubPacket"></param>
/// <param name="ArmorUpgradeRareSubPacket"></param>
/// <param name="Size"></param>
[PacketHeader("eq", PacketSource.Server)]
[GenerateSerializer(true)]
public record EqPacket
(
    [PacketIndex(0)]
    long CharacterId,
    [PacketIndex(1)]
    AuthorityType AuthorityType,
    [PacketIndex(2)]
    SexType Sex,
    [PacketIndex(3)]
    HairStyle HairStyle,
    [PacketIndex(4)]
    HairColor HairColor,
    [PacketIndex(5)]
    PlayerClass Class,
    [PacketIndex(6)]
    InEquipmentSubPacket EquipmentSubPacket,
    [PacketIndex(7)]
    UpgradeRareSubPacket? WeaponUpgradeRareSubPacket,
    [PacketIndex(8)]
    UpgradeRareSubPacket? ArmorUpgradeRareSubPacket,
    [PacketIndex(9)]
    byte Size
) : IPacket;
\ No newline at end of file

M Packets/NosSmooth.Packets/Server/Entities/StPacket.cs => Packets/NosSmooth.Packets/Server/Entities/StPacket.cs +2 -2
@@ 34,9 34,9 @@ public record StPacket
    [PacketIndex(3)]
    byte HeroLevel,
    [PacketIndex(4)]
    short HpPercentage,
    byte HpPercentage,
    [PacketIndex(5)]
    short MpPercentage,
    byte MpPercentage,
    [PacketIndex(6)]
    long Hp,
    [PacketIndex(7)]

A Packets/NosSmooth.Packets/Server/Maps/AtPacket.cs => Packets/NosSmooth.Packets/Server/Maps/AtPacket.cs +30 -0
@@ 0,0 1,30 @@
//
//  AtPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Maps;

/// <summary>
/// At packet. Sent when unknown TODO.
/// </summary>
/// <param name="CharacterId">The id of the character.</param>
/// <param name="MapId">The map id.</param>
/// <param name="X">The x coordinate of the character.</param>
/// <param name="Y">The y coordinate of the character.</param>
[PacketHeader("at", PacketSource.Server)]
[GenerateSerializer(true)]
public record AtPacket
(
    [PacketIndex(0)]
    long CharacterId,
    [PacketIndex(1)]
    int MapId,
    [PacketIndex(2)]
    short X,
    [PacketIndex(3)]
    short Y
) : IPacket;
\ No newline at end of file

M Packets/NosSmooth.Packets/Server/Maps/CMapPacket.cs => Packets/NosSmooth.Packets/Server/Maps/CMapPacket.cs +1 -1
@@ 21,7 21,7 @@ public record CMapPacket
    [PacketIndex(0)]
    byte Type,
    [PacketIndex(1)]
    short Id,
    int Id,
    [PacketIndex(2)]
    bool IsBaseType
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Maps/DropPacket.cs => Packets/NosSmooth.Packets/Server/Maps/DropPacket.cs +42 -0
@@ 0,0 1,42 @@
//
//  DropPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Maps;

/// <summary>
/// An item drop packet.
/// </summary>
/// <param name="ItemVNum">The item vnum identifier.</param>
/// <param name="DropId">The drop id.</param>
/// <param name="X">The map x.</param>
/// <param name="Y">The map y.</param>
/// <param name="Amount">The amount of the items on the ground.</param>
/// <param name="IsQuestRelated">Whether the item is a quest related item.</param>
/// <param name="Mode">UNKNOWN. Seems to be always 0.</param>
/// <param name="Parameter">UNKNOWN. Seems to be always -1.</param>
[PacketHeader("drop", PacketSource.Server)]
[GenerateSerializer(true)]
public record DropPacket
(
    [PacketIndex(0)]
    int ItemVNum,
    [PacketIndex(1)]
    long DropId,
    [PacketIndex(2)]
    short X,
    [PacketIndex(3)]
    short Y,
    [PacketIndex(4)]
    short Amount,
    [PacketIndex(5)]
    bool IsQuestRelated,
    [PacketIndex(6)]
    byte Mode,
    [PacketIndex(7)]
    byte Parameter
) : IPacket;
\ No newline at end of file

R Packets/NosSmooth.Packets/Server/Entities/InEquipmentSubPacket.cs => Packets/NosSmooth.Packets/Server/Maps/InEquipmentSubPacket.cs +9 -9
@@ 6,7 6,7 @@

using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Entities;
namespace NosSmooth.Packets.Server.Maps;

/// <summary>
/// Sub packet of <see cref="InPacket"/> present if the in packet


@@ 28,21 28,21 @@ namespace NosSmooth.Packets.Server.Entities;
public record InEquipmentSubPacket
(
    [PacketIndex(0)]
    long? HatVNum,
    int? HatVNum,
    [PacketIndex(1)]
    long? ArmorVNum,
    int? ArmorVNum,
    [PacketIndex(2)]
    long? MainWeaponVNum,
    int? MainWeaponVNum,
    [PacketIndex(3)]
    long? SecondaryWeaponVNum,
    int? SecondaryWeaponVNum,
    [PacketIndex(4)]
    long? MaskVNum,
    int? MaskVNum,
    [PacketIndex(5)]
    long? Fairy,
    int? FairyVNum,
    [PacketIndex(6)]
    long? CostumeSuitVNum,
    int? CostumeSuitVNum,
    [PacketIndex(7)]
    long? CostumeHatVNum,
    int? CostumeHatVNum,
    [PacketIndex(8)]
    short? WeaponSkin,
    [PacketIndex(9)]

R Packets/NosSmooth.Packets/Server/Entities/InItemSubPacket.cs => Packets/NosSmooth.Packets/Server/Maps/InItemSubPacket.cs +2 -2
@@ 6,7 6,7 @@

using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Entities;
namespace NosSmooth.Packets.Server.Maps;

/// <summary>
/// Sub packet of <see cref="InPacket"/> present if the in packet


@@ 20,7 20,7 @@ namespace NosSmooth.Packets.Server.Entities;
public record InItemSubPacket
(
    [PacketIndex(0)]
    long Amount,
    int Amount,
    [PacketIndex(1)]
    bool IsQuestRelative,
    [PacketIndex(2)]

R Packets/NosSmooth.Packets/Server/Entities/InNonPlayerSubPacket.cs => Packets/NosSmooth.Packets/Server/Maps/InNonPlayerSubPacket.cs +1 -1
@@ 9,7 9,7 @@ using NosSmooth.Packets.Enums.Entities;
using NosSmooth.PacketSerializer.Abstractions.Attributes;
using NosSmooth.PacketSerializer.Abstractions.Common;

namespace NosSmooth.Packets.Server.Entities;
namespace NosSmooth.Packets.Server.Maps;

/// <summary>
/// Sub packet of <see cref="InPacket"/> present if the in packet

R Packets/NosSmooth.Packets/Server/Entities/InPacket.cs => Packets/NosSmooth.Packets/Server/Maps/InPacket.cs +2 -2
@@ 8,7 8,7 @@ using NosSmooth.Packets.Enums;
using NosSmooth.PacketSerializer.Abstractions.Attributes;
using NosSmooth.PacketSerializer.Abstractions.Common;

namespace NosSmooth.Packets.Server.Entities;
namespace NosSmooth.Packets.Server.Maps;

/// <summary>
/// There is a new entity on the map present.


@@ 33,7 33,7 @@ public record InPacket
    [PacketConditionalIndex(1, "EntityType", false,  EntityType.Player)]
    NameString? Name,
    [PacketConditionalIndex(2, "EntityType", true, EntityType.Player)]
    long? VNum,
    int? VNum,
    [PacketConditionalIndex(3, "EntityType", false, EntityType.Player)]
    string? Unknown,
    [PacketIndex(4)]

R Packets/NosSmooth.Packets/Server/Entities/InPlayerSubPacket.cs => Packets/NosSmooth.Packets/Server/Maps/InPlayerSubPacket.cs +2 -2
@@ 10,7 10,7 @@ using NosSmooth.Packets.Server.Players;
using NosSmooth.Packets.Server.Weapons;
using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Entities;
namespace NosSmooth.Packets.Server.Maps;

/// <summary>
/// Sub packet for <see cref="InPacket"/>


@@ 94,7 94,7 @@ public record InPlayerSubPacket
    [PacketIndex(19)]
    string? FamilyName,
    [PacketIndex(20)]
    string ReputationIcon,
    byte ReputationIcon,
    [PacketIndex(21)]
    bool IsInvisible,
    [PacketIndex(22)]

A Packets/NosSmooth.Packets/Server/Maps/OutPacket.cs => Packets/NosSmooth.Packets/Server/Maps/OutPacket.cs +25 -0
@@ 0,0 1,25 @@
//
//  OutPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.Packets.Enums;
using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Maps;

/// <summary>
/// An entity has left the map.
/// </summary>
/// <param name="EntityType">The entity type.</param>
/// <param name="EntityId">The entity id.</param>
[PacketHeader("c_map", PacketSource.Server)]
[GenerateSerializer(true)]
public record OutPacket
(
    [PacketIndex(0)]
    EntityType EntityType,
    [PacketIndex(1)]
    long EntityId
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Portals/GpPacket.cs => Packets/NosSmooth.Packets/Server/Portals/GpPacket.cs +28 -0
@@ 0,0 1,28 @@
//
//  GpPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.Packets.Enums;
using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Portals;

[PacketHeader("gp", PacketSource.Server)]
[GenerateSerializer(true)]
public record GpPacket
(
    [PacketIndex(0)]
    short X,
    [PacketIndex(1)]
    short Y,
    [PacketIndex(2)]
    short TargetMapId,
    [PacketIndex(3)]
    PortalType? PortalType,
    [PacketIndex(4)]
    int PortalId,
    [PacketIndex(5)]
    bool IsDisabled
) : IPacket;
\ No newline at end of file

M Packets/NosSmooth.Packets/Server/Skills/SkiPacket.cs => Packets/NosSmooth.Packets/Server/Skills/SkiPacket.cs +2 -2
@@ 19,9 19,9 @@ namespace NosSmooth.Packets.Server.Skills;
public record SkiPacket
(
    [PacketIndex(0)]
    long PrimarySkillVNum,
    int PrimarySkillVNum,
    [PacketIndex(1)]
    long SecondarySkillVNum,
    int SecondarySkillVNum,
    [PacketListIndex(2, InnerSeparator = '|', ListSeparator = ' ')]
    IReadOnlyList<SkiSubPacket> SkillSubPackets
) : IPacket;
\ No newline at end of file

M Packets/NosSmooth.Packets/Server/Skills/SkiSubPacket.cs => Packets/NosSmooth.Packets/Server/Skills/SkiSubPacket.cs +1 -1
@@ 18,7 18,7 @@ namespace NosSmooth.Packets.Server.Skills;
public record SkiSubPacket
(
    [PacketIndex(0)]
    long SkillVNum,
    int SkillVNum,
    [PacketIndex(1)]
    byte Rank
) : IPacket;
\ No newline at end of file

M Packets/NosSmooth.Packets/Server/Skills/SrPacket.cs => Packets/NosSmooth.Packets/Server/Skills/SrPacket.cs +1 -1
@@ 22,5 22,5 @@ namespace NosSmooth.Packets.Server.Skills;
public record SrPacket
(
    [PacketIndex(0)]
    long SkillId
    short SkillId
) : IPacket;
\ No newline at end of file

Do not follow this link