From 0c354626c569c8d1fdfe97d6b5706db22168fb47 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sun, 8 Jan 2023 12:53:21 +0100 Subject: [PATCH] feat(packets): add raid packets --- .../Enums/Raids/RaidLeaveType.cs | 26 +++++++++++ .../Enums/Raids/RaidPacketType.cs | 45 +++++++++++++++++++ .../Server/Raids/RaidBfPacket.cs | 27 +++++++++++ .../Server/Raids/RaidMbfPacket.cs | 36 +++++++++++++++ .../Server/Raids/RaidPacket.cs | 39 ++++++++++++++++ .../Raids/RaidPlayerHealthsSubPacket.cs | 29 ++++++++++++ .../Server/Raids/RbossPacket.cs | 34 ++++++++++++++ .../Server/Raids/RdlstPacket.cs | 31 +++++++++++++ .../Server/Raids/RdlstSubPacket.cs | 45 +++++++++++++++++++ 9 files changed, 312 insertions(+) create mode 100644 Packets/NosSmooth.Packets/Enums/Raids/RaidLeaveType.cs create mode 100644 Packets/NosSmooth.Packets/Enums/Raids/RaidPacketType.cs create mode 100644 Packets/NosSmooth.Packets/Server/Raids/RaidBfPacket.cs create mode 100644 Packets/NosSmooth.Packets/Server/Raids/RaidMbfPacket.cs create mode 100644 Packets/NosSmooth.Packets/Server/Raids/RaidPacket.cs create mode 100644 Packets/NosSmooth.Packets/Server/Raids/RaidPlayerHealthsSubPacket.cs create mode 100644 Packets/NosSmooth.Packets/Server/Raids/RbossPacket.cs create mode 100644 Packets/NosSmooth.Packets/Server/Raids/RdlstPacket.cs create mode 100644 Packets/NosSmooth.Packets/Server/Raids/RdlstSubPacket.cs diff --git a/Packets/NosSmooth.Packets/Enums/Raids/RaidLeaveType.cs b/Packets/NosSmooth.Packets/Enums/Raids/RaidLeaveType.cs new file mode 100644 index 0000000..098eb59 --- /dev/null +++ b/Packets/NosSmooth.Packets/Enums/Raids/RaidLeaveType.cs @@ -0,0 +1,26 @@ +// +// RaidLeaveType.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.Server.Raids; + +namespace NosSmooth.Packets.Enums.Raids; + +/// +/// A sub type of +/// in case the type of the packet is Leave. +/// +public enum RaidLeaveType +{ + /// + /// The player has left the raid by himself. + /// + PlayerLeft = 0, + + /// + /// The raid is finished. + /// + RaidFinished = 1 +} \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Enums/Raids/RaidPacketType.cs b/Packets/NosSmooth.Packets/Enums/Raids/RaidPacketType.cs new file mode 100644 index 0000000..7888e7e --- /dev/null +++ b/Packets/NosSmooth.Packets/Enums/Raids/RaidPacketType.cs @@ -0,0 +1,45 @@ +// +// RaidPacketType.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.Server.Raids; + +namespace NosSmooth.Packets.Enums.Raids; + +/// +/// A type of . +/// +public enum RaidPacketType +{ + /// + /// A list of member ids follows. + /// + ListMembers = 0, + + /// + /// Character left or the raid is finished. + /// + Leave = 1, + + /// + /// Leader id follows (or -1 in case of leave). + /// + Leader = 2, + + /// + /// Hp, mp stats of players follow. + /// + PlayerHealths = 3, + + /// + /// Sent after raid start, but before refresh members. + /// + AfterStartBeforeRefreshMembers = 4, + + /// + /// Raid has just started. + /// + Start = 5 +} \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Raids/RaidBfPacket.cs b/Packets/NosSmooth.Packets/Server/Raids/RaidBfPacket.cs new file mode 100644 index 0000000..b6480b9 --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Raids/RaidBfPacket.cs @@ -0,0 +1,27 @@ +// +// RaidBfPacket.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.Raids; + +/// +/// Raid ui packet. Unknown function. +/// +/// Unknown TODO. +/// Unknown TODO. +/// Unknown TODO. +[PacketHeader("raidbf", PacketSource.Server)] +[GenerateSerializer(true)] +public record RaidBfPacket +( + [PacketIndex(0)] + byte Type, + [PacketIndex(1)] + byte WindowType, + [PacketIndex(2)] + byte Unknown +); \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Raids/RaidMbfPacket.cs b/Packets/NosSmooth.Packets/Server/Raids/RaidMbfPacket.cs new file mode 100644 index 0000000..49fc2b0 --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Raids/RaidMbfPacket.cs @@ -0,0 +1,36 @@ +// +// RaidMbfPacket.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.Raids; + +/// +/// Raid state of lives, lockers. +/// +/// +/// +/// +/// +/// +/// +[PacketHeader("raidmbf", PacketSource.Server)] +[GenerateSerializer(true)] +public record RaidMbfPacket +( + [PacketIndex(0)] + short MonsterLockerInitial, + [PacketIndex(1)] + short MonsterLockerCurrent, + [PacketIndex(2)] + short ButtonLockerInitial, + [PacketIndex(3)] + short ButtonLockerCurrent, + [PacketIndex(4)] + short CurrentLives, + [PacketIndex(5)] + short InitialLives +) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Raids/RaidPacket.cs b/Packets/NosSmooth.Packets/Server/Raids/RaidPacket.cs new file mode 100644 index 0000000..92457d5 --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Raids/RaidPacket.cs @@ -0,0 +1,39 @@ +// +// RaidPacket.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.Raids; +using NosSmooth.PacketSerializer.Abstractions.Attributes; + +namespace NosSmooth.Packets.Server.Raids; + +/// +/// Raid status packet. Sent for various raid operations. +/// +/// +/// For every type the rest of the packet is different. +/// Fields start with the type they are present for. +/// +/// The status type. +/// The id of the leader, null if leaving. Present only for Leader type. +/// The type of the leave type. Present only for Leave type. +/// The ids of players in the raid. Present only for ListMembers. +/// Health of the players. Present only for PlayerHealths. +[PacketHeader("raid", PacketSource.Server)] +[PacketHeader("raidf", PacketSource.Server)] +[GenerateSerializer(true)] +public record RaidPacket +( + [PacketIndex(0)] + RaidPacketType Type, + [PacketConditionalIndex(1, "Type", false, RaidPacketType.Leader, IsOptional = true)] + long? LeaderId, + [PacketConditionalIndex(2, "Type", false, RaidPacketType.Leave, IsOptional = true)] + RaidLeaveType? LeaveType, + [PacketConditionalListIndex(3, "Type", false, RaidPacketType.ListMembers, ListSeparator = ' ', IsOptional = true)] + IReadOnlyList? ListMembersPlayerIds, + [PacketConditionalListIndex(4, "Type", false, RaidPacketType.PlayerHealths, InnerSeparator = '.', ListSeparator = ' ', IsOptional = true)] + IReadOnlyList? PlayerHealths +) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Raids/RaidPlayerHealthsSubPacket.cs b/Packets/NosSmooth.Packets/Server/Raids/RaidPlayerHealthsSubPacket.cs new file mode 100644 index 0000000..8bd9feb --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Raids/RaidPlayerHealthsSubPacket.cs @@ -0,0 +1,29 @@ +// +// RaidPlayerHealthsSubPacket.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.Raids; + +/// +/// A sub packet of +/// present for PlayerHealths. Contains +/// information about player healths. +/// +/// The id of the player. +/// The hp percentage of the player. +/// The mp percentage of the player. +[PacketHeader(null, PacketSource.Server)] +[GenerateSerializer(true)] +public record RaidPlayerHealthsSubPacket +( + [PacketIndex(0)] + long PlayerId, + [PacketIndex(1)] + byte HpPercentage, + [PacketIndex(2)] + byte MpPercentage +) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Raids/RbossPacket.cs b/Packets/NosSmooth.Packets/Server/Raids/RbossPacket.cs new file mode 100644 index 0000000..51b950f --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Raids/RbossPacket.cs @@ -0,0 +1,34 @@ +// +// RbossPacket.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.Entities; +using NosSmooth.PacketSerializer.Abstractions.Attributes; + +namespace NosSmooth.Packets.Server.Raids; + +/// +/// Raid boss information. +/// +/// +/// EntityType and EntityId will be null in case of no boss. +/// +/// The boss entity type. +/// The boss entity id. +/// The max hp of the boss. +/// The vnum of the boss entity. +[PacketHeader("rboss", PacketSource.Server)] +[GenerateSerializer(true)] +public record RbossPacket +( + [PacketIndex(0)] + EntityType? EntityType, + [PacketIndex(1)] + long? EntityId, + [PacketIndex(2)] + int MaxHp, + [PacketIndex(3)] + int VNum +) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Raids/RdlstPacket.cs b/Packets/NosSmooth.Packets/Server/Raids/RdlstPacket.cs new file mode 100644 index 0000000..c140c56 --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Raids/RdlstPacket.cs @@ -0,0 +1,31 @@ +// +// RdlstPacket.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.Raids; + +/// +/// A packet containing information about raid members. +/// +/// The minimum needed level for the raid treasure. +/// The maximum needed level for the raid treasure. +/// Unknown TODO. +/// Information about members in the raid. +[PacketHeader("rdlst", PacketSource.Server)] +[PacketHeader("rdlstf", PacketSource.Server)] +[GenerateSerializer(true)] +public record RdlstPacket +( + [PacketIndex(0)] + byte MinimumLevel, + [PacketIndex(1)] + byte MaximumLevel, + [PacketIndex(2)] + byte RaidType, + [PacketIndex(3)] + IReadOnlyList Players +) : IPacket; \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Raids/RdlstSubPacket.cs b/Packets/NosSmooth.Packets/Server/Raids/RdlstSubPacket.cs new file mode 100644 index 0000000..7c5fe6f --- /dev/null +++ b/Packets/NosSmooth.Packets/Server/Raids/RdlstSubPacket.cs @@ -0,0 +1,45 @@ +// +// RdlstSubPacket.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.Players; +using NosSmooth.PacketSerializer.Abstractions.Attributes; +using NosSmooth.PacketSerializer.Abstractions.Common; + +namespace NosSmooth.Packets.Server.Raids; + +/// +/// A sub packet of . +/// Information about a member of the raid. +/// +/// The level of the player. +/// The morph vnum of the player. +/// The class of the player. +/// The current number of deaths in the raid. +/// The name of the player. +/// The sex of the player. +/// The id of the player entity. +/// The hero level of the player. +[PacketHeader(null, PacketSource.Server)] +[GenerateSerializer(true)] +public record RdlstSubPacket +( + [PacketIndex(0)] + byte Level, + [PacketIndex(1)] + int? MorphVNum, + [PacketIndex(2)] + PlayerClass Class, + [PacketIndex(3)] + byte Deaths, + [PacketIndex(4)] + NameString Name, + [PacketIndex(5)] + SexType Sex, + [PacketIndex(6)] + long Id, + [PacketIndex(7)] + short? HeroLevel +); \ No newline at end of file -- 2.48.1