~ruther/NosSmooth

09429d182b86565f561a902741b1b06f1d64979c — František Boháček 3 years ago 1b594fc
feat: add packets (ncif, u_as, pusle, msg, say, st, stat, c_mode, lev, ski, sr)
A Core/NosSmooth.Packets/Enums/Chat/MessageType.cs => Core/NosSmooth.Packets/Enums/Chat/MessageType.cs +46 -0
@@ 0,0 1,46 @@
//
//  Message.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.

namespace NosSmooth.Packets.Enums.Chat;

/// <summary>
/// The type of the message.
/// </summary>
public enum MessageType
{
    /// <summary>
    /// Default message in chat.
    /// </summary>
    Default = 0,

    /// <summary>
    /// Unknown.
    /// </summary>
    Notification = 1,

    /// <summary>
    /// The message is a shout (shown at the top of screen on the whole width.)
    /// </summary>
    Shout = 2,

    /// <summary>
    /// The message is shown at the center of the screen.
    /// </summary>
    Center = 3,

    /// <summary>
    /// The message is shown at the bottom center of the screen.
    /// </summary>
    /// <remarks>
    /// Only few players with the highest reputation can send this..
    /// </remarks>
    Hero = 4,

    /// <summary>
    /// Unknown.
    /// </summary>
    DefaultAndNotification
}
\ No newline at end of file

A Core/NosSmooth.Packets/Enums/Chat/SayColor.cs => Core/NosSmooth.Packets/Enums/Chat/SayColor.cs +35 -0
@@ 0,0 1,35 @@
//
//  SayColor.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.

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

/// <summary>
/// The color in the chat.
/// </summary>
public enum SayColor
{
    Default = 0,
    BubbleOnly = 1,
    LightGreen = 3,
    DarkGrey = 4,
    Orange = 5,
    Blue = 6,
    LightYellow = 7,
    OrangeWithName = 8,
    Yellow = 10,
    Red = 11,
    Green = 12,
    LightPurple = 13,
    LightPurpleWithName = 14,
    DarkPurpleWithName = 15,
    WhiteTimeout = 20,
    PurpleFromNosville = 30,
    PurpleFromCylloan = 31,
}
#pragma warning restore CS1591
#pragma warning restore SA1602
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Client/Battle/NcifPacket.cs => Core/NosSmooth.Packets/Packets/Client/Battle/NcifPacket.cs +28 -0
@@ 0,0 1,28 @@
//
//  NcifPacket.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.Attributes;
using NosSmooth.Packets.Enums;

namespace NosSmooth.Packets.Packets.Client.Battle;

/// <summary>
/// Client sends this when focusing an entity and then every x seconds again.
/// </summary>
/// <remarks>
/// The server should respond with "st" packet.
/// </remarks>
/// <param name="EntityType">The type of the focused entity.</param>
/// <param name="TargetId">The focused entity id.</param>
[PacketHeader("ncif", PacketSource.Client)]
[GenerateSerializer]
public record NcifPacket
(
    [PacketIndex(0)]
    EntityType EntityType,
    [PacketIndex(1)]
    long TargetId
) : IPacket;
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Client/Battle/UseAOESkillPacket.cs => Core/NosSmooth.Packets/Packets/Client/Battle/UseAOESkillPacket.cs +27 -0
@@ 0,0 1,27 @@
//
//  UseAOESkillPacket.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.Attributes;

namespace NosSmooth.Packets.Packets.Client.Battle;

/// <summary>
/// Sent to use a skill that is targeted at position.
/// </summary>
/// <param name="SkillId">The id of the skill.</param>
/// <param name="PositionX">The x coordinate where to target to.</param>
/// <param name="PositionY">The y coordinate where to targe to.</param>
[PacketHeader("u_as", PacketSource.Client)]
[GenerateSerializer]
public record UseAOESkillPacket
(
    [PacketIndex(0)]
    long SkillId,
    [PacketIndex(1)]
    short PositionX,
    [PacketIndex(2)]
    short PositionY
);
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Client/Battle/UseSkillPacket.cs => Core/NosSmooth.Packets/Packets/Client/Battle/UseSkillPacket.cs +32 -0
@@ 0,0 1,32 @@
//
//  UseSkillPacket.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.Attributes;
using NosSmooth.Packets.Enums;

namespace NosSmooth.Packets.Packets.Client.Battle;

/// <summary>
/// Sent to use regular skill.
/// </summary>
/// <remarks>
/// Contains the position etc. for dashes.
/// </remarks>
[PacketHeader("u_s", PacketSource.Client)]
[GenerateSerializer]
public record UseSkillPacket
(
    [PacketIndex(0)]
    long SkillId,
    [PacketIndex(1)]
    EntityType TargetEntityType,
    [PacketIndex(2)]
    long TargetId,
    [PacketIndex(3, IsOptional = true)]
    short? MapX,
    [PacketIndex(4, IsOptional = true)]
    short? MapY
);
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Client/Misc/PulsePacket.cs => Core/NosSmooth.Packets/Packets/Client/Misc/PulsePacket.cs +27 -0
@@ 0,0 1,27 @@
//
//  PulsePacket.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.Attributes;

namespace NosSmooth.Packets.Packets.Client.Misc;

/// <summary>
/// Heartbeat packet.
/// </summary>
/// <remarks>
/// Sent every minute the client is connected on the server.
/// </remarks>
/// <param name="Seconds">The number of seconds till connected. (should be sent only as multiples of 60)</param>
/// <param name="Unknown">Unknown TODO</param>
[GenerateSerializer]
[PacketHeader("pulse", PacketSource.Client)]
public record PulsePacket
(
    [PacketIndex(0)]
    long Seconds,
    [PacketIndex(1)]
    short Unknown
);
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Server/Chat/MsgPacket.cs => Core/NosSmooth.Packets/Packets/Server/Chat/MsgPacket.cs +25 -0
@@ 0,0 1,25 @@
//
//  MsgPacket.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.Attributes;
using NosSmooth.Packets.Enums.Chat;

namespace NosSmooth.Packets.Packets.Server.Chat;

/// <summary>
/// Contains message that was sent in chat, shouted etc.
/// </summary>
/// <param name="Type">The type of the message.</param>
/// <param name="Message">The message text.</param>
[PacketHeader("msg", PacketSource.Server)]
[GenerateSerializer]
public record MsgPacket
(
    [PacketIndex(0)]
    MessageType Type,
    [PacketGreedyIndex(1)]
    string Message
) : IPacket;
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Server/Chat/SayPacket.cs => Core/NosSmooth.Packets/Packets/Server/Chat/SayPacket.cs +32 -0
@@ 0,0 1,32 @@
//
//  SayPacket.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.Attributes;
using NosSmooth.Packets.Enums;
using NosSmooth.Packets.Enums.Chat;

namespace NosSmooth.Packets.Packets.Server.Chat;

/// <summary>
/// Sent when someone says something.
/// </summary>
/// <param name="EntityType">The entity type that said something.</param>
/// <param name="EntityId">The id of the entity that said something.</param>
/// <param name="Color">The color of the message in chat.</param>
/// <param name="Message">The message received.</param>
[PacketHeader("say", PacketSource.Server)]
[GenerateSerializer]
public record SayPacket
(
    [PacketIndex(0)]
    EntityType EntityType,
    [PacketIndex(1)]
    long EntityId,
    [PacketIndex(2)]
    SayColor Color,
    [PacketGreedyIndex(3)]
    string Message
) : IPacket;
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Server/Entities/StPacket.cs => Core/NosSmooth.Packets/Packets/Server/Entities/StPacket.cs +46 -0
@@ 0,0 1,46 @@
//
//  StPacket.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.Collections.Generic;
using NosSmooth.Packets.Attributes;
using NosSmooth.Packets.Enums;

namespace NosSmooth.Packets.Packets.Server.Entities;

/// <summary>
/// Sent as a response to "ncif" packet.
/// </summary>
/// <param name="EntityType">The type of the entity.</param>
/// <param name="EntityId">The id of the entity.</param>
/// <param name="Level">The level of the entity.</param>
/// <param name="HeroLevel">The hero level. (for players only)</param>
/// <param name="HpPercentage">The current hp percentage.</param>
/// <param name="MpPercentage">The current mp percentage.</param>
/// <param name="Hp">The current amount of hp.</param>
/// <param name="Mp">The current amount of mp.</param>
[PacketHeader("st", PacketSource.Server)]
[GenerateSerializer]
public record StPacket
(
    [PacketIndex(0)]
    EntityType EntityType,
    [PacketIndex(1)]
    long EntityId,
    [PacketIndex(2)]
    byte Level,
    [PacketIndex(3)]
    byte HeroLevel,
    [PacketIndex(4)]
    short HpPercentage,
    [PacketIndex(5)]
    short MpPercentage,
    [PacketIndex(6)]
    long Hp,
    [PacketIndex(7)]
    long Mp,
    [PacketListIndex(8, ListSeparator = ' ')]
    List<long> BuffVNums
) : IPacket;
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Server/Entities/StatPacket.cs => Core/NosSmooth.Packets/Packets/Server/Entities/StatPacket.cs +36 -0
@@ 0,0 1,36 @@
//
//  StatPacket.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.Attributes;

namespace NosSmooth.Packets.Packets.Server.Entities;

/// <summary>
/// Sent when player takes damage, heals or changes options.
/// </summary>
/// <param name="Hp"></param>
/// <param name="HpMaximum"></param>
/// <param name="Mp"></param>
/// <param name="MpMaximum"></param>
/// <param name="Unknown">Unknown TODO.</param>
/// <param name="Option">Contains blockages (family block, exchange block etc). TODO add correct options.</param>
[PacketHeader("stat", PacketSource.Server)]
[GenerateSerializer]
public record StatPacket
(
    [PacketIndex(0)]
    long Hp,
    [PacketIndex(1)]
    long HpMaximum,
    [PacketIndex(2)]
    long Mp,
    [PacketIndex(3)]
    long MpMaximum,
    [PacketIndex(4)]
    int Unknown,
    [PacketIndex(5)]
    long Option
) : IPacket;
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Server/Players/CModePacket.cs => Core/NosSmooth.Packets/Packets/Server/Players/CModePacket.cs +43 -0
@@ 0,0 1,43 @@
//
//  CModePacket.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.Attributes;
using NosSmooth.Packets.Enums;

namespace NosSmooth.Packets.Packets.Server.Players;

/// <summary>
/// TODO
/// </summary>
/// <param name="EntityType">The type of the entity the packet is for.</param>
/// <param name="EntityId">The id of the entity.</param>
/// <param name="MorphVNum">The morph vnum (used for special cards and such).</param>
/// <param name="MorphUpgrade">The upgrade of the morph. (wings)</param>
/// <param name="MorphDesign">The design of the wings.</param>
/// <param name="MorphBonus">Unknown TODO</param>
/// <param name="Size">The size of the entity on the screen.</param>
/// <param name="MorphSkin">Unknown TODO</param>
[PacketHeader("c_mode", PacketSource.Server)]
[GenerateSerializer]
public record CModePacket
(
    [PacketIndex(0)]
    EntityType EntityType,
    [PacketIndex(1)]
    long EntityId,
    [PacketIndex(2)]
    long MorphVNum,
    [PacketIndex(3)]
    byte MorphUpgrade,
    [PacketIndex(4)]
    short MorphDesign,
    [PacketIndex(5)]
    byte MorphBonus,
    [PacketIndex(6)]
    byte Size,
    [PacketIndex(7)]
    byte MorphSkin
) : IPacket;
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Server/Players/LevPacket.cs => Core/NosSmooth.Packets/Packets/Server/Players/LevPacket.cs +54 -0
@@ 0,0 1,54 @@
//
//  LevPacket.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.Attributes;

namespace NosSmooth.Packets.Packets.Server.Players;

/// <summary>
/// Sent on map change.
/// </summary>
/// <remarks>
/// Contains information about the playing character.
/// </remarks>
/// <param name="Level">The level of the player.</param>
/// <param name="LevelXp">The xp in level. TODO</param>
/// <param name="JobLevel">The job level.</param>
/// <param name="JobLevelXp">The xp in job level. TODO</param>
/// <param name="XpLoad">Unknown TODO</param>
/// <param name="JobXpLoad">Unknown TODO</param>
/// <param name="Reputation">The reputation of the player.</param>
/// <param name="SkillCp">The skill cp. (Used for learning skills)</param>
/// <param name="HeroXp">The xp in hero level. TODO</param>
/// <param name="HeroLevel">The hero level. (shown as (+xx))</param>
/// <param name="HeroXpLoad">Unknown TODO</param>
[PacketHeader("lev", PacketSource.Server)]
[GenerateSerializer]
public record LevPacket
(
    [PacketIndex(0)]
    byte Level,
    [PacketIndex(1)]
    long LevelXp,
    [PacketIndex(2)]
    byte JobLevel,
    [PacketIndex(3)]
    long JobLevelXp,
    [PacketIndex(4)]
    long XpLoad,
    [PacketIndex(5)]
    long JobXpLoad,
    [PacketIndex(6)]
    long Reputation,
    [PacketIndex(7)]
    int SkillCp,
    [PacketIndex(8)]
    long HeroXp,
    [PacketIndex(9)]
    byte HeroLevel,
    [PacketIndex(10)]
    long HeroXpLoad
) : IPacket;
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Server/Skills/SkiPacket.cs => Core/NosSmooth.Packets/Packets/Server/Skills/SkiPacket.cs +29 -0
@@ 0,0 1,29 @@
//
//  SkiPacket.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.Collections.Generic;
using System.ComponentModel;
using NosSmooth.Packets.Attributes;

namespace NosSmooth.Packets.Packets.Server.Skills;

/// <summary>
/// Information about skills, sent when changing sp, map etc.
/// </summary>
/// <param name="PrimarySkillId">The primary skill id.</param>
/// <param name="SecondarySkillId">The secondary skill id. (may be same as primary in some cases, like for special cards).</param>
/// <param name="SkillSubPackets">The rest of the skills.</param>
[PacketHeader("ski", PacketSource.Server)]
[GenerateSerializer]
public record SkiPacket
(
    [PacketIndex(0)]
    long PrimarySkillId,
    [PacketIndex(1)]
    long SecondarySkillId,
    [PacketListIndex(2, InnerSeparator = '.', ListSeparator = ' ')]
    IReadOnlyList<SkiSubPacket> SkillSubPackets
) : IPacket;
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Server/Skills/SkiSubPacket.cs => Core/NosSmooth.Packets/Packets/Server/Skills/SkiSubPacket.cs +24 -0
@@ 0,0 1,24 @@
//
//  SkiSubPacket.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.Attributes;

namespace NosSmooth.Packets.Packets.Server.Skills;

/// <summary>
/// Sub packet for <see cref="SkiPacket"/> containing information about a skill.
/// </summary>
/// <param name="SkillId">The id of the skill.</param>
/// <param name="Rank">The rank of the skill.</param>
[PacketHeader(null, PacketSource.Server)]
[GenerateSerializer]
public record SkiSubPacket
(
    [PacketIndex(0)]
    long SkillId,
    [PacketIndex(1)]
    byte Rank
) : IPacket;
\ No newline at end of file

A Core/NosSmooth.Packets/Packets/Server/Skills/SrPacket.cs => Core/NosSmooth.Packets/Packets/Server/Skills/SrPacket.cs +23 -0
@@ 0,0 1,23 @@
//
//  SrPacket.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.CodeDom.Compiler;
using NosSmooth.Packets.Attributes;

namespace NosSmooth.Packets.Packets.Server.Skills;

/// <summary>
/// Skill cooldown reset.
/// </summary>
/// <remarks>
/// The client will mark the skill as ready only after this packet is received.
/// Do not rely on skill used + cooldown time. You will get kicked out of the sever
/// after some time (on official).
/// </remarks>
/// <param name="SkillId">The id of the skill that is resetted.</param>
[PacketHeader("sr", PacketSource.Server)]
[GenerateSerializer]
public record SrPacket(long SkillId) : IPacket;
\ No newline at end of file

Do not follow this link