~ruther/NosSmooth

6df124413179825b09c8827cd7251d6d52e66183 — František Boháček 3 years ago 3d95287
fix: use new packets in game responders
M Core/NosSmooth.Game/Data/Characters/Character.cs => Core/NosSmooth.Game/Data/Characters/Character.cs +2 -2
@@ 66,7 66,7 @@ public record Character
    FactionType? Faction = default,
    short Size = default,
    AuthorityType AuthorityType = default,
    SexType Gender = default,
    SexType Sex = default,
    HairStyle HairStyle = default,
    HairColor HairColor = default,
    PlayerClass Class = default,


@@ 89,7 89,7 @@ public record Character
    Faction,
    Size,
    AuthorityType,
    Gender,
    Sex,
    HairStyle,
    HairColor,
    Class,

M Core/NosSmooth.Game/Data/Entities/Player.cs => Core/NosSmooth.Game/Data/Entities/Player.cs +2 -2
@@ 24,7 24,7 @@ namespace NosSmooth.Game.Data.Entities;
/// <param name="Faction"></param>
/// <param name="Size"></param>
/// <param name="AuthorityType"></param>
/// <param name="Gender"></param>
/// <param name="Sex"></param>
/// <param name="HairStyle"></param>
/// <param name="HairColor"></param>
/// <param name="Class"></param>


@@ 47,7 47,7 @@ public record Player
    FactionType? Faction = default,
    short Size = default,
    AuthorityType AuthorityType = default,
    SexType Gender = default,
    SexType Sex = default,
    HairStyle HairStyle = default,
    HairColor HairColor = default,
    PlayerClass Class = default,

M Core/NosSmooth.Game/Data/Social/Family.cs => Core/NosSmooth.Game/Data/Social/Family.cs +1 -1
@@ 12,4 12,4 @@ namespace NosSmooth.Game.Data.Social;
/// <param name="Id">The id of the family.</param>
/// <param name="Name">The name of the family.</param>
/// <param name="Level">The level of the entity.</param>
public record Family(string? Id, string? Name, byte Level);
\ No newline at end of file
public record Family(string? Id, string? Name, byte? Level);
\ No newline at end of file

M Core/NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs => Core/NosSmooth.Game/Extensions/ServiceCollectionExtensions.cs +1 -3
@@ 11,7 11,6 @@ using NosSmooth.Game.Apis;
using NosSmooth.Game.Events.Core;
using NosSmooth.Game.PacketHandlers.Characters;
using NosSmooth.Game.PacketHandlers.Entities;
using NosSmooth.Game.PacketHandlers.Login;

namespace NosSmooth.Game.Extensions;



@@ 37,8 36,7 @@ public static class ServiceCollectionExtensions
            .AddPacketResponder<CharacterInitResponder>()
            .AddPacketResponder<SkillResponder>()
            .AddPacketResponder<WalkResponder>()
            .AddPacketResponder<SkillUsedResponder>()
            .AddPacketResponder<CListPacketResponder>();
            .AddPacketResponder<SkillUsedResponder>();

        serviceCollection
            .AddTransient<NostaleChatPacketApi>()

M Core/NosSmooth.Game/PacketHandlers/Characters/CharacterInitResponder.cs => Core/NosSmooth.Game/PacketHandlers/Characters/CharacterInitResponder.cs +6 -6
@@ 44,21 44,21 @@ public class CharacterInitResponder : IPacketResponder<CInfoPacket>, IPacketResp
        {
            _game.Character = character = character with
            {
                /*Id = packet.CharacterId,
                Id = packet.CharacterId,
                AuthorityType = packet.Authority,
                Gender = packet.Gender,
                Sex = packet.Sex,
                HairStyle = packet.HairStyle,
                HairColor = packet.HairColor,
                Class = packet.Class,
                Icon = packet.Icon,
                Compliment = packet.Compliment,
                Morph = (character.Morph ?? new Morph(packet.Morph, packet.MorphUpgrade)) with
                Morph = (character.Morph ?? new Morph(packet.MorphVNum, packet.MorphUpgrade)) with
                {
                    VNum = packet.Morph, Upgrade = packet.MorphUpgrade
                    VNum = packet.MorphVNum, Upgrade = packet.MorphUpgrade
                },
                ArenaWinner = packet.ArenaWinner,
                Invisible = packet.Invisible,
                Family = new Family(packet.FamilyId, packet.FamilyName, packet.FamilyLevel)*/
                Invisible = packet.IsInvisible,
                Family = new Family(packet.FamilyId, packet.FamilyName, packet.FamilyLevel)
            };
        }


M Core/NosSmooth.Game/PacketHandlers/Entities/SkillUsedResponder.cs => Core/NosSmooth.Game/PacketHandlers/Entities/SkillUsedResponder.cs +8 -12
@@ 11,6 11,7 @@ using NosSmooth.Game.Events.Core;
using NosSmooth.Game.Events.Players;
using NosSmooth.Game.Extensions;
using NosSmooth.Packets.Enums;
using NosSmooth.Packets.Packets.Server.Battle;
using NosSmooth.Packets.Packets.Server.Skills;
using Remora.Results;



@@ 41,14 42,9 @@ public class SkillUsedResponder : IPacketResponder<SuPacket>, IPacketResponder<S
        var packet = packetArgs.Packet;
        var character = _game.Character;

        if (packet.EntityType != EntityType.Player)
        if (character is not null && character.Id == packet.CasterEntityId && character.Skills is not null)
        {
            return Result.FromSuccess();
        }

        if (character is not null && character.Id != packet.VisualId && character.Skills is not null)
        {
            var skillResult = character.Skills.TryGetSkill(packet.SkillVnum);
            var skillResult = character.Skills.TryGetSkill(packet.SkillVNum);

            if (skillResult.IsDefined(out var skillEntity))
            {


@@ 63,8 59,8 @@ public class SkillUsedResponder : IPacketResponder<SuPacket>, IPacketResponder<S
                    character,
                    character.Id,
                    skillResult.IsSuccess ? skillEntity : null,
                    packet.SkillVnum,
                    packet.TargetId,
                    packet.SkillVNum,
                    packet.TargetEntityId,
                    new Position { X = packet.PositionX, Y = packet.PositionY }
                ),
                ct);


@@ 76,10 72,10 @@ public class SkillUsedResponder : IPacketResponder<SuPacket>, IPacketResponder<S
                new SkillUsedEvent
                (
                    null,
                    packet.VisualId,
                    packet.CasterEntityId,
                    null,
                    packet.SkillVnum,
                    packet.TargetId,
                    packet.SkillVNum,
                    packet.TargetEntityId,
                    new Position
                    {
                        X = packet.PositionX, Y = packet.PositionY

Do not follow this link