private void SendNotifyData(NecClient client)
        {
            List <Character> characters = Database.SelectCharactersBySoulId(client.Soul.Id);

            if (characters == null || characters.Count <= 0)
            {
                Logger.Debug(client, "No characters found");
                return;
            }

            foreach (Character character in characters)
            {
                IBuffer res = BufferProvider.Provide();

                res.WriteByte(character.Slot);            //character slot, 0 for left, 1 for middle, 2 for right
                res.WriteInt32(character.Id);             //  Character ID
                res.WriteFixedString(character.Name, 91); // 0x5B | 91x 1 byte

                res.WriteInt32(0);                        // 0 = Alive | 1 = Dead
                res.WriteInt32(character.Level);          //character level stat
                res.WriteInt32(1);                        //todo (unknown)
                res.WriteUInt32(character.ClassId);       //class stat

                //Consolidated Frequently Used Code
                LoadEquip.BasicTraits(res, character);
                LoadEquip.SlotSetup(res, character, 19);
                LoadEquip.EquipItems(res, character, 19);
                LoadEquip.EquipSlotBitMask(res, character, 19);

                //19x 4 byte //item quality(+#) or aura? 10 = +7, 19 = +6,(maybe just wep aura)
                res.WriteInt32(10);              //Right Hand    //1 for weapon
                res.WriteInt32(10);              //Left Hand     //2 for Shield
                res.WriteInt32(10);              //Torso         //16 for torso
                res.WriteInt32(10);              //Head          //08 for head
                res.WriteInt32(10);              //Legs          //32 for legs
                res.WriteInt32(10);              //Arms          //64 for Arms
                res.WriteInt32(10);              //Feet          //128 for feet
                res.WriteInt32(004);             //???Cape
                res.WriteInt32(0);               //???Ring
                res.WriteInt32(0);               //???Earring
                res.WriteInt32(0);               //???Necklace
                res.WriteInt32(0);               //???Belt
                res.WriteInt32(10);              //Avatar Torso
                res.WriteInt32(10);              //Avatar Feet
                res.WriteInt32(10);              //Avatar Arms
                res.WriteInt32(10);              //Avatar Legs
                res.WriteInt32(10);              //Avatar Head
                res.WriteInt32(10);              //???Talk Ring
                res.WriteInt32(00);              //???Quiver
                res.WriteByte(19);               //Number of equipment to display
                res.WriteInt32(character.MapId); //map location ID
                Router.Send(client, (ushort)MsgPacketId.recv_chara_notify_data, res, ServerType.Msg);
            }
        }
        protected override IBuffer ToBuffer()
        {
            IBuffer res14 = BufferProvider.Provide();

            res14.WriteUInt32(_deadBody.InstanceId);          //Instance ID of dead body
            res14.WriteUInt32(_deadBody.CharacterInstanceId); //Reference to actual player's instance ID
            res14.WriteCString($"{_deadBody.SoulName}");      // Soul name
            res14.WriteCString($"{_deadBody.CharaName}");     // Character name
            res14.WriteFloat(_deadBody.X);                    // X
            res14.WriteFloat(_deadBody.Y);                    // Y
            res14.WriteFloat(_deadBody.Z);                    // Z
            res14.WriteByte(_deadBody.Heading);               // Heading
            res14.WriteInt32(_deadBody.Level);

            int numEntries = 19;

            res14.WriteInt32(numEntries); //less than or equal to 19
            //Consolidated Frequently Used Code
            LoadEquip.SlotSetup(res14, _character, numEntries);

            res14.WriteInt32(numEntries);
            //Consolidated Frequently Used Code
            LoadEquip.EquipItems(res14, _character, numEntries);

            res14.WriteInt32(numEntries);
            //Consolidated Frequently Used Code
            LoadEquip.EquipSlotBitMask(res14, _character, numEntries);

            //Consolidated Frequently Used Code
            LoadEquip.BasicTraits(res14, _character);

            res14.WriteInt32(_deadBody
                             .ConnectionState);    // 0 = bag, 1 for dead? (Can't enter soul form if this isn't 0 or 1 i think).
            res14.WriteInt32(_deadBody.ModelType); //4 = ash pile, not sure what this is.
            res14.WriteInt32(0);
            res14.WriteInt32(_deadBody
                             .deathPose);                  //death pose 0 = faced down, 1 = head chopped off, 2 = no arm, 3 = faced down, 4 = chopped in half, 5 = faced down, 6 = faced down, 7 and up "T-pose" the body (ONLY SEND 1 IF YOU ARE CALLING THIS FOR THE FIRST TIME)
            res14.WriteByte(_deadBody
                            .CriminalStatus);              //crim status (changes icon on the end also), 0 = white, 1 = yellow, 2 = red, 3 = red with crim icon,
            res14.WriteByte(_deadBody.BeginnerProtection); // (bool) Beginner protection
            res14.WriteInt32(1);

            return(res14);
        }
Exemple #3
0
        protected override IBuffer ToBuffer()
        {
            int numEntries       = 19; // 1 to 19 equipment.  Setting to 0 because NPCS don't wear gear.
            int numStatusEffects = 128;

            if (_npcSpawn.ModelId > 52000 /*CharacterModelUpperLimit*/)
            {
                numEntries = 0;
            } //ToDo find NPCs using chara models and build a table containing their equipment IDs

            IBuffer res = BufferProvider.Provide();

            res.WriteUInt32(_npcSpawn.InstanceId); // InstanceId
            res.WriteInt32(_npcSpawn.NpcId);       // NPC Serial ID from "npc.csv"
            res.WriteByte(0);                      // interaction type. 0:chat bubble. 1:none 2:press f
            res.WriteCString(_npcSpawn.Name);      //Name
            res.WriteCString(_npcSpawn.Title);     //Title
            res.WriteFloat(_npcSpawn.X);           //X Pos
            res.WriteFloat(_npcSpawn.Y);           //Y Pos
            res.WriteFloat(_npcSpawn.Z);           //Z Pos
            res.WriteByte(_npcSpawn.Heading);      //view offset

            res.WriteInt32(numEntries);            // Number of equipment Slots
            //Consolidated Frequently Used Code
            LoadEquip.SlotSetup(res, _character, numEntries);
            //sub_483420
            res.WriteInt32(numEntries); // Number of equipment Slots
            //Consolidated Frequently Used Code
            LoadEquip.EquipItems(res, _character, numEntries);
            //sub_483420
            res.WriteInt32(numEntries); // Number of equipment Slots
            //Consolidated Frequently Used Code
            LoadEquip.EquipSlotBitMask(res, _character, numEntries);

            res.WriteInt32(_npcSpawn.ModelId); //NPC Model from file "model_common.csv"
            res.WriteInt16(_npcSpawn.Size);    //NPC Model Size
            res.WriteByte(4);                  //Hair ID for Character models
            res.WriteByte(5);                  //Hair Color ID for Character models
            res.WriteByte(3);                  //Face ID for Character models
            res.WriteInt32(0b10100110);        //BITMASK for NPC State
            //0bxxxxxxx1 - 1 dead / 0 alive | for character models only
            //0bxxxxxx1x - 1 Soul form visible / 0 soul form invisible
            //0bxxxxx1xx -
            //0bxxxx1xxx - 1 Show Emoticon / 0 Hide Emoticon
            //0bxxx1xxxx -
            //0bxx1xxxxx -
            //0bx1xxxxxx - 1 blinking  / 0 solid
            //0b1xxxxxxx -
            res.WriteInt32(Util.GetRandomNumber(1, 9)); //npc Emoticon above head 1 for skull. 2-9 different hearts
            res.WriteInt32(_npcSpawn
                           .Status);                    //From  NPC.CSV column C  |   //horse: 4 TP machine:5 Ghost: 6 Illusion 7. Dungeun: 8 Stone 9. Ggate 1.  torch 13,14,15. power spot :22  event:23 ??:16,17,18
            res.WriteFloat(_npcSpawn.Status_X);         //x for particle effects from Int32 above From NPC.CSV column D
            res.WriteFloat(_npcSpawn.Status_Y);         //y for particle effects from Int32 above From NPC.CSV column E
            res.WriteFloat(_npcSpawn.Status_Z);         //z for particle effects from Int32 above From NPC.CSV column F
            res.WriteInt32(numStatusEffects);           //number of status effects. 128 Max.
            for (int i = 0; i < numStatusEffects; i++)
            {
                res.WriteInt32(0);
                res.WriteInt32(0);
                res.WriteInt32(0);
            }

            return(res);
        }
        protected override IBuffer ToBuffer()
        {
            int numEntries       = 02;   //Max of 16 Equipment Slots for Monster.  cmp to 0x10
            int numStatusEffects = 0x80; //Statuses effects. Max 128

            if (_monsterSpawn.ModelId > 52000 /*CharacterModelUpperLimit*/)
            {
                numEntries = 0;
            } //ToDo find any videos with monsters holding weapons.

            IBuffer res = BufferProvider.Provide();

            res.WriteUInt32(_monsterSpawn.InstanceId);
            res.WriteCString(_monsterSpawn.Name);
            res.WriteCString(_monsterSpawn.Title);
            res.WriteFloat(_monsterSpawn.X);
            res.WriteFloat(_monsterSpawn.Y);
            res.WriteFloat(_monsterSpawn.Z);
            res.WriteByte(_monsterSpawn.Heading);
            res.WriteInt32(_monsterSpawn.MonsterId); //Monster Serial ID
            res.WriteInt32(_monsterSpawn.ModelId);   //Monster Model ID
            res.WriteInt16(_monsterSpawn.Size);

            res.WriteInt32(numEntries); // Number of equipment Slots
            //Consolidated Frequently Used Code
            LoadEquip.SlotSetup(res, _character, numEntries);

            //sub_483420
            res.WriteInt32(numEntries); // Number of equipment Slots
            //Consolidated Frequently Used Code
            LoadEquip.EquipItems(res, _character, numEntries);

            //Equipment bitmask
            res.WriteInt32(numEntries); // cmp to 0x10 = 16
            for (int i = 0; i < numEntries; i++)
            {
                res.WriteInt64(2 ^ i);
            }

            res.WriteInt32(0b10000000); //BITMASK for Monster State
            //0bxxxxxxx1 - 1 Dead / 0 Alive  |
            //0bxxxxxx1x - 1 crouching / 0 standing
            //0bxxxxx1xx -
            //0bxxxx1xxx - 1 crouching / 0 standing
            //0bxxx1xxxx -
            //0bxx1xxxxx -
            //0bx1xxxxxx - 1 Aggro Battle  / 0 Normal    | (for when you join a map and the monster is in battle)
            //0b1xxxxxxx -
            res.WriteInt64(1); // item Id ?
            res.WriteInt64(1); // item Id ?
            res.WriteInt64(1); // item Id ?
            res.WriteByte(231);
            res.WriteByte(232);
            res.WriteInt32(_monsterSpawn.Hp.current); //Current HP
            res.WriteInt32(_monsterSpawn.Hp.max);     //Max HP
            res.WriteInt32(numStatusEffects);         // cmp to 0x80 = 128
            for (int i = 0; i < numStatusEffects; i++)
            {
                res.WriteInt32(0); // status effect ID. set to i
                res.WriteInt32(0); //1 on 0 off
                res.WriteInt32(0);
            }

            return(res);
        }
        public override void Execute(string[] command, NecClient client, ChatMessage message,
                                     List <ChatResponse> responses)
        {
            if (command[0] == null)
            {
                responses.Add(ChatResponse.CommandError(client, $"Invalid argument: {command[0]}"));
                return;
            }

            Character character2 = null;

            if (uint.TryParse(command[1], out uint x))
            {
                IInstance instance = Server.Instances.GetInstance(x);
                if (instance is Character character)
                {
                    character2 = character;
                }
                else if (instance is DeadBody deadbody)
                {
                    responses.Add(ChatResponse.CommandError(client, $"That's a dead body man. have some respect!"));
                    character2            = new Character();
                    character2.InstanceId = deadbody.InstanceId;
                }
                else
                {
                    responses.Add(ChatResponse.CommandError(client, $"Please provide a character instance id"));
                    return;
                }
            }

            if (!int.TryParse(command[2], out int y))
            {
                try
                {
                    string binaryString = command[2];
                    binaryString = binaryString.Replace("0b", "");
                    Logger.Debug(binaryString);
                    y = Convert.ToInt32(binaryString, 2);
                }
                catch
                {
                    responses.Add(ChatResponse.CommandError(client, $"Please provide a value to test"));
                    return;
                }
            }


            switch (command[0])
            {
            case "hp":
                IBuffer res = BufferProvider.Provide();
                res.WriteInt32(y);
                character2.Hp.setCurrent(y);
                Router.Send(client, (ushort)AreaPacketId.recv_chara_update_hp, res, ServerType.Area);
                break;

            case "dead":
                SendBattleReportStartNotify(client, character2);
                //recv_battle_report_noact_notify_dead = 0xCDC9,
                IBuffer res2 = BufferProvider.Provide();
                res2.WriteUInt32(character2.InstanceId);
                res2.WriteInt32(
                    y);     // death type? 1 = death, 2 = death and message, 3 = unconscious, beyond that = nothing
                res2.WriteInt32(0);
                res2.WriteInt32(0);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_battle_report_noact_notify_dead, res2,
                            ServerType.Area);
                SendBattleReportEndNotify(client, character2);
                break;

            case "pose":
                IBuffer res3 = BufferProvider.Provide();
                //recv_battle_attack_pose_start_notify = 0x7CB2,
                res3.WriteInt32(y);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_battle_attack_pose_start_notify, res3,
                            ServerType.Area);
                break;

            case "pose2":
                IBuffer res4 = BufferProvider.Provide();
                res4.WriteUInt32(character2.InstanceId); //Character ID
                res4.WriteInt32(y);                      //Character pose
                Router.Send(client.Map, (ushort)AreaPacketId.recv_chara_pose_notify, res4, ServerType.Area,
                            client);

                break;

            case "emotion":
                //recv_emotion_notify_type = 0xF95B,
                IBuffer res5 = BufferProvider.Provide();
                res5.WriteUInt32(character2.InstanceId);
                res5.WriteInt32(y);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_emotion_notify_type, res5, ServerType.Area);
                break;

            case "deadstate":
                //recv_charabody_notify_deadstate = 0xCC36, // Parent = 0xCB94 // Range ID = 03
                IBuffer res6 = BufferProvider.Provide();
                res6.WriteUInt32(character2.InstanceId);
                res6.WriteInt32(
                    y);     //4 here causes a cloud and the model to disappear, 5 causes a mist to happen and disappear
                res6.WriteInt32(y);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_charabody_notify_deadstate, res6,
                            ServerType.Area);
                break;

            case "start":
                SendBattleReportStartNotify(client, character2);
                IBuffer res7 = BufferProvider.Provide();
                //recv_battle_report_action_item_enchant = 0x6BDC,
                res7.WriteInt32(517);
                res7.WriteInt32(y);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_battle_report_action_item_enchant, res7,
                            ServerType.Area);
                SendBattleReportEndNotify(client, character2);
                break;

            case "end":
                IBuffer res8 = BufferProvider.Provide();
                Router.Send(client.Map, (ushort)AreaPacketId.recv_battle_report_end_notify, res8, ServerType.Area);
                break;

            case "gimmick":
                //recv_data_notify_gimmick_data = 0xBFE9,
                IBuffer res9 = BufferProvider.Provide();
                res9.WriteInt32(y);     //Gimmick instance id
                res9.WriteFloat(client.Character.X + 100);
                res9.WriteFloat(client.Character.Y);
                res9.WriteFloat(client.Character.Z);
                res9.WriteByte(client.Character.Heading);
                res9.WriteInt32(y);     //Gimmick number (from gimmick.csv)
                res9.WriteInt32(0);     //Gimmick State
                Router.Send(client.Map, (ushort)AreaPacketId.recv_data_notify_gimmick_data, res9, ServerType.Area);
                break;

            case "bodystate":     ///State of your dead body
                //recv_charabody_state_update_notify = 0x1A0F,
                IBuffer res10 = BufferProvider.Provide();
                res10.WriteUInt32(character2.InstanceId);
                res10.WriteInt32(y);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_charabody_state_update_notify, res10,
                            ServerType.Area);
                responses.Add(ChatResponse.CommandError(client,
                                                        $"setting bodyState to {y} for character {character2.Name}"));

                break;

            case "charastate":     //state of your regular body
                //recv_chara_notify_stateflag = 0x23D3,
                IBuffer res11 = BufferProvider.Provide();
                res11.WriteUInt32(character2.InstanceId);
                res11.WriteInt32(y);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_chara_notify_stateflag, res11, ServerType.Area);
                responses.Add(ChatResponse.CommandError(client,
                                                        $"setting charaState to {y} for character {character2.Name}"));
                break;

            case "spirit":
                //recv_charabody_notify_spirit = 0x36A6,
                IBuffer res12 = BufferProvider.Provide();
                res12.WriteUInt32(character2.InstanceId);
                res12.WriteByte((byte)y);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_charabody_notify_spirit, res12, ServerType.Area);
                break;

            case "abyss":     //lil marker in soul form of where you died if you jump off the map
                //recv_charabody_self_notify_abyss_stead_pos = 0x679B,
                IBuffer res13 = BufferProvider.Provide();
                res13.WriteFloat(character2.X);
                res13.WriteFloat(character2.Y);
                res13.WriteFloat(character2.Z);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_charabody_self_notify_abyss_stead_pos, res13,
                            ServerType.Area);
                break;

            case "charadata":
                RecvDataNotifyCharaData cData = new RecvDataNotifyCharaData(character2,
                                                                            client.Soul.Name /*Should be client of supplied instanceID. this is a band-aid*/);
                Router.Send(Server.Clients.GetAll(), cData.ToPacket());
                break;

            case "charabodydata":
                //recv_data_notify_charabody_data = 0x906A,
                DeadBody _deadBody = Server.Instances.GetInstance(character2.DeadBodyInstanceId) as DeadBody;
                IBuffer  res14     = BufferProvider.Provide();
                res14.WriteUInt32(character2.DeadBodyInstanceId); //Instance ID of dead body
                res14.WriteUInt32(character2.InstanceId);         //Reference to actual player's instance ID
                res14.WriteCString("soulname");                   // Soul name
                res14.WriteCString($"{character2.Name}");         // Character name
                res14.WriteFloat(character2.X + 200);             // X
                res14.WriteFloat(character2.Y);                   // Y
                res14.WriteFloat(character2.Z);                   // Z
                res14.WriteByte(character2.Heading);              // Heading
                res14.WriteInt32(character2.Level);               //??level?


                int numEntries = 19;
                res14.WriteInt32(numEntries);     //less than or equal to 19
                //Consolidated Frequently Used Code
                LoadEquip.SlotSetup(res14, character2, numEntries);

                res14.WriteInt32(numEntries);
                //Consolidated Frequently Used Code
                LoadEquip.EquipItems(res14, character2, numEntries);

                res14.WriteInt32(numEntries);
                //Consolidated Frequently Used Code
                LoadEquip.EquipSlotBitMask(res14, character2, numEntries);

                //Consolidated Frequently Used Code
                LoadEquip.BasicTraits(res14, character2);

                res14.WriteInt32(_deadBody
                                 .ConnectionState);    // 0 = bag, 1 for dead? (Can't enter soul form if this isn't 0 or 1 i think).
                res14.WriteInt32(_deadBody.ModelType); //4 = ash pile, not sure what this is.
                res14.WriteInt32(y);
                res14.WriteInt32(_deadBody
                                 .deathPose);                  //death pose 0 = faced down, 1 = head chopped off, 2 = no arm, 3 = faced down, 4 = chopped in half, 5 = faced down, 6 = faced down, 7 and up "T-pose" the body (ONLY SEND 1 IF YOU ARE CALLING THIS FOR THE FIRST TIME)
                res14.WriteByte(_deadBody
                                .CriminalStatus);              //crim status (changes icon on the end also), 0 = white, 1 = yellow, 2 = red, 3 = red with crim icon,
                res14.WriteByte(_deadBody.BeginnerProtection); // (bool) Beginner protection
                res14.WriteInt32(1);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_data_notify_charabody_data, res14,
                            ServerType.Area);
                break;

            case "scaleopen":
                IBuffer res0 = BufferProvider.Provide();
                res0.WriteInt32(0);     //1 = cinematic, 0 Just start the event without cinematic
                res0.WriteByte(0);
                Router.Send(client, (ushort)AreaPacketId.recv_event_start, res0, ServerType.Area);

                IBuffer res15 = BufferProvider.Provide();
                //recv_raisescale_view_open = 0xC25D, // Parent = 0xC2E5 // Range ID = 01  // was 0xC25D
                res15.WriteInt16(1); //Basic revival rate %
                res15.WriteInt16(5); //Penalty %
                res15.WriteInt16(
                    (short)y);       //Offered item % (this probably changes with recv_raisescale_update_success_per)
                res15.WriteInt16(4); //Dimento medal addition %
                Router.Send(client, (ushort)AreaPacketId.recv_raisescale_view_open, res15, ServerType.Area);
                break;

            case "event":
                IBuffer res16 = BufferProvider.Provide();
                //recv_event_start = 0x1B5C,
                res16.WriteInt32(0);
                res16.WriteByte(0);
                Router.Send(client, (ushort)AreaPacketId.recv_event_start, res16, ServerType.Area);

                IBuffer res17 = BufferProvider.Provide();
                //recv_event_quest_report = 0xE07E,
                res17.WriteInt32(0);
                Router.Send(client, (ushort)AreaPacketId.recv_event_quest_report, res17, ServerType.Area);

                IBuffer res18 = BufferProvider.Provide();
                //recv_event_block_message_end_no_object = 0x1AB,
                //Router.Send(client, (ushort)AreaPacketId.recv_event_block_message_end_no_object, res18, ServerType.Area);

                IBuffer res19 = BufferProvider.Provide();
                Router.Send(client, (ushort)AreaPacketId.recv_event_sync, res19, ServerType.Area);
                break;

            case "popup":
                IBuffer res22 = BufferProvider.Provide();
                //recv_event_start = 0x1B5C,
                res22.WriteInt32(0);
                res22.WriteByte((byte)y);
                //Router.Send(client, (ushort)AreaPacketId.recv_event_start, res22, ServerType.Area);

                IBuffer res21 = BufferProvider.Provide();
                //recv_normal_system_message = 0xAE2B,
                res21.WriteCString("ToBeFound");
                Router.Send(client, (ushort)AreaPacketId.recv_normal_system_message, res21, ServerType.Area);

                IBuffer res23 = BufferProvider.Provide();
                //recv_event_end = 0x99D,
                res23.WriteByte((byte)y);
                //Router.Send(client, (ushort)AreaPacketId.recv_event_end, res23, ServerType.Area);
                break;

            case "recv":
                IBuffer res24 = BufferProvider.Provide();
                //recv_auction_receive_item_r = 0xB1CA,
                res24.WriteInt32(y);
                Router.Send(client, (ushort)AreaPacketId.recv_auction_receive_gold_r, res24, ServerType.Area);
                break;

            case "string":
                IBuffer res26 = BufferProvider.Provide();
                //recv_charabody_notify_loot_item = 0x8CDE, // Parent = 0x8CC6 // Range ID = 01
                res26.WriteByte(0);
                res26.WriteByte(0);
                res26.WriteInt16(0);

                res26.WriteInt16((short)y);
                res26.WriteCString("adad");     // Length 0x31
                res26.WriteCString("adad");     // Length 0x5B
                Router.Send(client, (ushort)AreaPacketId.recv_charabody_notify_loot_item, res26, ServerType.Area);
                break;

            case "ac":
                IBuffer res27 = BufferProvider.Provide();
                //recv_item_update_ac
                res27.WriteInt64(10200101);
                res27.WriteInt16((short)y);
                Router.Send(client, (ushort)AreaPacketId.recv_item_update_ac, res27, ServerType.Area);
                break;

            case "alignment":
                IBuffer res28 = BufferProvider.Provide();
                //recv_chara_update_alignment_param = 0xB435,
                res28.WriteInt32(1);
                res28.WriteInt32(2);
                res28.WriteInt32(3);
                Router.Send(client, (ushort)AreaPacketId.recv_chara_update_alignment_param, res28,
                            ServerType.Area);
                break;

            case "shop":
                IBuffer res29 = BufferProvider.Provide();
                //recv_shop_notify_open = 0x52FD, // Parent = 0x5243 // Range ID = 02
                res29.WriteInt16((short)y);      //Shop type
                res29.WriteInt32(0);
                res29.WriteInt32(0);
                res29.WriteByte(0);
                Router.Send(client, (ushort)AreaPacketId.recv_shop_notify_open, res29, ServerType.Area);
                break;

            case "dura":

                IBuffer res30 = BufferProvider.Provide();
                res30.WriteInt64(10200101);
                res30.WriteInt32(y);     // MaxDura points
                Router.Send(client, (ushort)AreaPacketId.recv_item_update_maxdur, res30, ServerType.Area);

                //recv_item_update_durability = 0x1F5A,
                IBuffer res31 = BufferProvider.Provide();
                res31.WriteInt64(10200101);
                res31.WriteInt32(y - 1);
                Router.Send(client, (ushort)AreaPacketId.recv_item_update_durability, res31, ServerType.Area);
                break;

            case "sc":
                IBuffer res32 = BufferProvider.Provide();
                //recv_shop_sell_check_r = 0x4E8D,
                res32.WriteInt32(0);
                Router.Send(client, (ushort)AreaPacketId.recv_shop_sell_check_r, res32, ServerType.Area);
                break;

            case "view":
                IBuffer res33 = BufferProvider.Provide();
                //recv_chara_view_landing_notify = 0x14DA,
                res33.WriteInt32(y);
                Router.Send(client.Map, (ushort)AreaPacketId.recv_chara_view_landing_notify, res33,
                            ServerType.Area);
                break;

            case "itemnum":
                IBuffer res34 = BufferProvider.Provide();
                //recv_item_update_num = 0x5F8,
                res34.WriteInt64(10200101);
                res34.WriteByte(25);
                Router.Send(client, (ushort)AreaPacketId.recv_item_update_num, res34, ServerType.Area);
                break;

            case "damage":
                int hp = character2.Hp.current;
                client.Character.Hp.Modify(-hp, character2.InstanceId);
                IBuffer res35 = BufferProvider.Provide();
                res35.WriteInt32(hp - hp);
                Router.Send(client, (ushort)AreaPacketId.recv_chara_update_hp, res35, ServerType.Area);
                break;

            case "union":
                IBuffer res36 = BufferProvider.Provide();
                res36.WriteUInt32(client.Character.InstanceId);
                res36.WriteInt32(8888 /*client.Character.UnionId*/);
                res36.WriteCString("Trade_Union");
                Router.Send(client.Map, (ushort)AreaPacketId.recv_chara_notify_union_data, res36, ServerType.Area);
                break;

            case "xunion":
                IBuffer res37 = BufferProvider.Provide();
                res37.WriteUInt32(client.Character.InstanceId);
                res37.WriteInt32(0 /*client.Character.UnionId*/);
                res37.WriteCString("");
                Router.Send(client.Map, (ushort)AreaPacketId.recv_chara_notify_union_data, res37, ServerType.Area);
                break;

            case "itemforth":
                IBuffer res38 = BufferProvider.Provide();
                res38.WriteUInt32(client.Character.InstanceId); //item ID?
                res38.WriteInt32(10200101);                     //Owner going 'forth'  id?
                res38.WriteUInt32(client.Character.InstanceId); //item state setting?
                Router.Send(client.Map, (ushort)AreaPacketId.recv_chara_update_notify_item_forth, res38,
                            ServerType.Area);
                break;

            case "disconnect":
                NecClient DeadManClient = Server.Clients.GetByCharacterInstanceId(x);
                IBuffer   res39         = BufferProvider.Provide();
                res39.WriteUInt32(client.Character.InstanceId);
                res39.WriteUInt32(client.Character.InstanceId);
                res39.WriteUInt32(client.Character.InstanceId);
                res39.WriteUInt32(client.Character.InstanceId);
                res39.WriteUInt32(client.Character.InstanceId);
                res39.WriteUInt32(client.Character.InstanceId);
                res39.WriteUInt32(client.Character.InstanceId);
                Router.Send(DeadManClient, (ushort)AreaPacketId.recv_chara_update_notify_item_forth, res39,
                            ServerType.Area);
                break;

            case "crime":
                //for (byte i = 0; i < y; i++)
            {
                NecClient crimeClient = Server.Clients.GetByCharacterInstanceId(x);
                IBuffer   res40       = BufferProvider.Provide();
                res40.WriteUInt32(crimeClient.Character.InstanceId);
                res40.WriteByte((byte)y);
                client.Character.criminalState = (byte)y;
                Logger.Debug($"Setting crime level for Character {crimeClient.Character.Name} to {y}");
                Router.Send(crimeClient, (ushort)AreaPacketId.recv_chara_update_notify_crime_lv, res40,
                            ServerType.Area);
                Router.Send(crimeClient.Map, (ushort)AreaPacketId.recv_charabody_notify_crime_lv, res40,
                            ServerType.Area, crimeClient);
                Thread.Sleep(400);
            }
            break;

            case "inherit":
                //for (byte i = 0; i < y; i++)
            {
                NecClient inheritClient = Server.Clients.GetByCharacterInstanceId(x);
                IBuffer   res41         = BufferProvider.Provide();
                res41.WriteInt32(y);
                res41.WriteInt32(0x64);        //less than or equal to 0x64
                for (int i = 0; i < 0x64; i++) //limit is the int32 above
                {
                    res41.WriteInt32(i);
                    // TODO what ip is this? Area Msg ?? use -> Server.Setting.DataAreaIpAddress or Server.Setting.DataMsgIpAddress
                    res41.WriteFixedString("127.0.0.1", 0x10);     //size is 0x10
                }

                res41.WriteUInt32(client.Character.InstanceId);
                // TODO what ip is this? Area Msg ?? use -> Server.Setting.DataAreaIpAddress or Server.Setting.DataMsgIpAddress
                res41.WriteFixedString("127.0.0.1", 0x10);     //size is 0x10
                res41.WriteByte((byte)y);
                Router.Send(inheritClient, (ushort)MsgPacketId.recv_chara_get_inheritinfo_r, res41,
                            ServerType.Msg);

                Thread.Sleep(400);
            }
            break;

            default:
                Logger.Error($"There is no recv of type : {command[0]} ");
                break;
            }
        }
        private void SendDataGetSelfCharaData(NecClient client)
        {
            IBuffer res = BufferProvider.Provide();

            //sub_4953B0 - characteristics
            //Consolidated Frequently Used Code
            LoadEquip.BasicTraits(res, client.Character);

            //sub_484720 - combat/leveling info
            Logger.Debug($"Character ID Loading : {client.Character.Id}");
            res.WriteUInt32(client.Character.InstanceId); // InstanceId
            res.WriteUInt32(client.Character.ClassId);    // class
            res.WriteInt16(client.Character.Level);       // current level //+50 Temporary client.Character.Level
            res.WriteInt64(91978348);                     // current exp
            res.WriteInt64(50);                           // soul exp
            res.WriteInt64(96978348);                     // exp needed to level
            res.WriteInt64(1100);                         // soul exp needed to level
            res.WriteInt32(client.Character.Hp.current);  // current hp
            res.WriteInt32(client.Character.Mp.current);  // current mp
            res.WriteInt32(client.Character.Od.current);  // current od
            res.WriteInt32(client.Character.Hp.max);      // max hp
            res.WriteInt32(client.Character.Mp.max);      // maxmp
            res.WriteInt32(client.Character.Od.max);      // max od
            res.WriteInt32(500);                          // current guard points
            res.WriteInt32(600);                          // max guard points
            res.WriteInt32(1238);                         // value/100 = current weight
            res.WriteInt32(1895);                         // value/100 = max weight
            res.WriteByte(200);                           // condition

            // total stat level includes bonus'?
            res.WriteUInt16(client.Character.Strength);              // str
            res.WriteUInt16(client.Character.vitality);              // vit
            res.WriteInt16((short)(client.Character.dexterity + 3)); // dex
            res.WriteUInt16(client.Character.agility);               // agi
            res.WriteUInt16(client.Character.intelligence);          // int
            res.WriteUInt16(client.Character.piety);                 // pie
            res.WriteInt16((short)(client.Character.luck + 4));      // luk

            // mag atk atrb
            res.WriteInt16(5);  // fire
            res.WriteInt16(52); // water
            res.WriteInt16(58); // wind
            res.WriteInt16(45); // earth
            res.WriteInt16(33); // light
            res.WriteInt16(12); // dark
            res.WriteInt16(0);
            res.WriteInt16(0);
            res.WriteInt16(0);

            // mag def atrb
            res.WriteInt16(5);  // fire
            res.WriteInt16(52); // water
            res.WriteInt16(58); // wind
            res.WriteInt16(45); // earth
            res.WriteInt16(33); // light
            res.WriteInt16(12); // dark
            res.WriteInt16(0);
            res.WriteInt16(0);
            res.WriteInt16(0);

            //status change resistance
            res.WriteInt16(11); // Poison
            res.WriteInt16(12); // Paralyze
            res.WriteInt16(13); // Stone
            res.WriteInt16(14); // Faint
            res.WriteInt16(15); // Blind
            res.WriteInt16(16); // Sleep
            res.WriteInt16(17); // Silent
            res.WriteInt16(18); // Charm
            res.WriteInt16(19); // confus
            res.WriteInt16(20); // fear
            res.WriteInt16(21); //possibly EXP Boost Gauge. trying to find it

            // gold and alignment?
            res.WriteInt64(client.Character.AdventureBagGold);        // gold
            res.WriteUInt32(client.Character.Alignmentid);            // AlignmentId
            res.WriteInt32(6000);                                     // lawful
            res.WriteInt32(5000);                                     // neutral
            res.WriteInt32(6100);                                     // chaos
            res.WriteInt32(Util.GetRandomNumber(90400101, 90400130)); // title from honor.csv

            //sub_484980
            res.WriteInt32(1); // ac eval calculation?
            res.WriteInt32(1); // ac eval calculation?
            res.WriteInt32(1); // ac eval calculation?

            // characters stats
            res.WriteUInt16(client.Character.Strength);          // str
            res.WriteUInt16(client.Character.vitality);          // vit
            res.WriteInt16((short)(client.Character.dexterity)); // dex
            res.WriteUInt16(client.Character.agility);           // agi
            res.WriteUInt16(client.Character.intelligence);      // int
            res.WriteUInt16(client.Character.piety);             // pie
            res.WriteInt16((short)(client.Character.luck));      // luk

            // nothing
            res.WriteInt16(1);
            res.WriteInt16(2);
            res.WriteInt16(3);
            res.WriteInt16(4);
            res.WriteInt16(5);
            res.WriteInt16(6);
            res.WriteInt16(7);
            res.WriteInt16(8);
            res.WriteInt16(9);


            // nothing
            res.WriteInt16(1);
            res.WriteInt16(2);
            res.WriteInt16(3);
            res.WriteInt16(4);
            res.WriteInt16(5);
            res.WriteInt16(6);
            res.WriteInt16(7);
            res.WriteInt16(8);
            res.WriteInt16(9);

            // nothing
            res.WriteInt16(1);
            res.WriteInt16(2);
            res.WriteInt16(3);
            res.WriteInt16(4);
            res.WriteInt16(5);
            res.WriteInt16(6);
            res.WriteInt16(7);
            res.WriteInt16(8);
            res.WriteInt16(9);
            res.WriteInt16(10);
            res.WriteInt16(11);


            //sub_484B00 map ip and connection
            res.WriteInt32(client.Character.MapId);               //MapSerialID
            res.WriteInt32(client.Character.MapId);               //MapID
            res.WriteFixedString(Settings.DataAreaIpAddress, 65); //IP
            res.WriteUInt16(Settings.AreaPort);                   //Port

            //sub_484420 // Map Spawn coord
            res.WriteFloat(client.Character.X);      //X Pos
            res.WriteFloat(client.Character.Y);      //Y Pos
            res.WriteFloat(client.Character.Z);      //Z Pos
            res.WriteByte(client.Character.Heading); //view offset

            //sub_read_int32 skill point
            res.WriteInt32(101); // skill point

            //sub_483420 character state like alive/dead/invis
            res.WriteInt32(0); //-254 GM

            //sub_494AC0
            res.WriteByte(20);   // soul level
            res.WriteInt32(22);  // current soul points
            res.WriteInt32(790); // soul point bar value (percenage of current/max)
            res.WriteInt32(120); // max soul points
            res.WriteByte(0);    // 0 is white,1 yellow 2 red 3+ skull
            res.WriteByte(0);    //Beginner protection (bool)
            res.WriteByte(50);   //Level cap
            res.WriteByte(0);
            res.WriteByte(0);
            res.WriteByte(0);

            //sub_read_3-int16 unknown
            res.WriteInt16(50); // HP Consumption Rate?
            res.WriteInt16(50); // MP Consumption Rate?
            res.WriteInt16(50); // OD Consumption Rate (if greater than currentOD, Can not sprint)

            //sub_4833D0
            res.WriteInt64(0);

            //sub_4833D0
            res.WriteInt64(0);

            //sub_4834A0
            res.WriteFixedString($"{client.Soul.Name} Shop", 97); //Shopname

            //sub_4834A0
            res.WriteFixedString($"{client.Soul.Name} Comment", 385); //Comment

            //sub_494890
            res.WriteByte(0); //Bool 0 off 1 on

            //sub_4834A0
            res.WriteFixedString($"{client.Soul.Name} chatbox?", 385); //Chatbox?

            //sub_494890
            res.WriteByte(1); //Bool

            //sub_483420
            int numEntries = 19;

            res.WriteInt32(numEntries); //has to be less than 19(defines how many int32s to read?)

            //Consolidated Frequently Used Code
            LoadEquip.SlotSetup(res, client.Character, numEntries);


            //sub_483420
            res.WriteInt32(numEntries); //has to be less than 19

            //Consolidated Frequently Used Code
            LoadEquip.EquipItems(res, client.Character, numEntries);

            //sub_483420
            res.WriteInt32(numEntries);

            LoadEquip.EquipSlotBitMask(res, client.Character, numEntries);

            //sub_483420
            numEntries = 128;
            res.WriteInt32(numEntries); //has to be less than 128

            //sub_485A70
            for (int k = 0; k < numEntries; k++) //status buffs / debuffs
            {
                res.WriteInt32(0);               //set to k
                res.WriteInt32(0);
                res.WriteInt32(0);
            }

            Router.Send(client, (ushort)AreaPacketId.recv_data_get_self_chara_data_r, res, ServerType.Area);
        }