public void CAvatarChangeReq(GameSession session, CAvatarChangeReqMessage message)
        {
            var plr = session.Player;

            Logger.Debug()
            .Account(session)
            .Message($"Avatar sync - {JsonConvert.SerializeObject(message.Unk1, Formatting.Indented)}")
            .Write();

            if (message.Unk2.Length > 0)
            {
                Logger.Warn()
                .Account(session)
                .Message($"Unk2: {JsonConvert.SerializeObject(message.Unk2, Formatting.Indented)}")
                .Write();
            }

            var @char = plr.CharacterManager.CurrentCharacter;
            var unk1  = new ChangeAvatarUnk1Dto
            {
                AccountId = plr.Account.Id,
                Skills    = @char.Skills.GetItems().Select(item => item?.ItemNumber ?? 0).ToArray(),
                Weapons   = @char.Weapons.GetItems().Select(item => item?.ItemNumber ?? 0).ToArray(),
                Costumes  = new ItemNumber[(int)CostumeSlot.Max],
                Unk5      = message.Unk1.Unk5,
                Unk6      = message.Unk1.Unk6,
                Unk7      = message.Unk1.Unk7,
                Unk8      = message.Unk1.Unk8,
                Gender    = plr.CharacterManager.CurrentCharacter.Gender,
                HP        = plr.GetMaxHP(),
                Unk11     = message.Unk1.Unk11
            };

            // If no item equipped use the default item the character was created with
            for (CostumeSlot slot = 0; slot < CostumeSlot.Max; slot++)
            {
                var item = plr.CharacterManager.CurrentCharacter.Costumes.GetItem(slot)?.ItemNumber ?? 0;
                switch (slot)
                {
                case CostumeSlot.Hair:
                    if (item == 0)
                    {
                        item = @char.Hair.ItemNumber;
                    }
                    break;

                case CostumeSlot.Face:
                    if (item == 0)
                    {
                        item = @char.Face.ItemNumber;
                    }
                    break;

                case CostumeSlot.Shirt:
                    if (item == 0)
                    {
                        item = @char.Shirt.ItemNumber;
                    }
                    break;

                case CostumeSlot.Pants:
                    if (item == 0)
                    {
                        item = @char.Pants.ItemNumber;
                    }
                    break;

                case CostumeSlot.Gloves:
                    if (item == 0)
                    {
                        item = @char.Gloves.ItemNumber;
                    }
                    break;

                case CostumeSlot.Shoes:
                    if (item == 0)
                    {
                        item = @char.Shoes.ItemNumber;
                    }
                    break;
                }
                unk1.Costumes[(int)slot] = item;
            }

            plr.Room.Broadcast(new SAvatarChangeAckMessage(unk1, message.Unk2));
        }
Exemple #2
0
 public SAvatarChangeAckMessage(ChangeAvatarUnk1Dto unk1, ChangeAvatarUnk2Dto[] unk2)
 {
     Unk1 = unk1;
     Unk2 = unk2;
 }
Exemple #3
0
 public CAvatarChangeReqMessage()
 {
     Unk1 = new ChangeAvatarUnk1Dto();
     Unk2 = Array.Empty <ChangeAvatarUnk2Dto>();
 }
Exemple #4
0
 public GameAvatarChangeAckMessage()
 {
     Unk1 = new ChangeAvatarUnk1Dto();
     Unk2 = Array.Empty <ChangeAvatarUnk2Dto>();
 }