コード例 #1
0
        public static void Inventory_Update(Packet packet)
        {
            int type = packet.ReadUInt8();

            if (type == 1)
            {
                byte   slot  = packet.ReadUInt8();
                ushort count = packet.ReadUInt16();
                int    index = Data.inventoryslot.IndexOf(slot);
                if (count > 0)
                {
                    Data.inventorycount[index] = count;
                }
                else
                {
                    Data.inventoryid.RemoveAt(index);
                    Data.inventorytype.RemoveAt(index);
                    Data.inventoryslot.RemoveAt(index);
                    Data.inventorycount.RemoveAt(index);
                    Data.inventorydurability.RemoveAt(index);
                    Data.inventorylevel.RemoveAt(index);
                    Data.inventoryname.RemoveAt(index);
                    Data.maxdurability.RemoveAt(index);
                }
            }
            ItemsCount.CountManager();
            Globals.MainWindow.UpdateInventory();
        }
コード例 #2
0
        public static void Inventory_Update1(Packet packet)
        {
            Packet vienas = packet;
            int    check  = packet.ReadUInt8();

            if (check == 1)
            {
                int typ = packet.ReadUInt8();
                if (typ == 0) // Inventory <> Inventory
                {
                    byte   inv_1   = packet.ReadUInt8();
                    byte   inv_2   = packet.ReadUInt8();
                    ushort count   = packet.ReadUInt16();
                    int    index_1 = Data.inventoryslot.IndexOf(inv_1);
                    int    index_2 = Data.inventoryslot.IndexOf(inv_2);
                    if (index_2 == -1)
                    {
                        // No item, Moving !
                        Data.inventoryslot[index_1] = inv_2;
                        if (itemid != 0)
                        {
                            Data.inventoryslot[Data.inventorytype.IndexOf(Items_Info.itemstypelist[Items_Info.itemsidlist.IndexOf(itemid)])] = intendtomove;
                            itemid       = 0;
                            intendtomove = 0;
                        }
                    }
                    else
                    {
                        // The item exist !
                        if (Data.inventorytype[index_1] == Data.inventorytype[index_2])
                        {
                            // Items Are Same, Merge It !
                            if (Data.inventorycount[index_2] == Items_Info.items_maxlist[Items_Info.itemstypelist.IndexOf(Data.inventorytype[index_2])])
                            {
                                // Items Are Maxed, Move It !
                                Data.inventoryslot[index_1] = inv_2;
                                Data.inventoryslot[index_2] = inv_1;
                            }
                            else
                            {
                                // Items Are Same, Merge It !
                                if (Data.inventorycount[index_1] == count)
                                {
                                    // Merged Everything, Delete The First Item !
                                    Data.inventorycount[index_2] += count;

                                    Data.inventoryid.RemoveAt(index_1);
                                    Data.inventorytype.RemoveAt(index_1);
                                    Data.inventorycount.RemoveAt(index_1);
                                    Data.inventoryslot.RemoveAt(index_1);
                                    Data.inventorydurability.RemoveAt(index_1);
                                    Data.inventorylevel.RemoveAt(index_1);
                                    Data.inventoryname.RemoveAt(index_1);
                                    Data.maxdurability.RemoveAt(index_1);
                                }
                                else
                                {
                                    // Merged Not Everything, Recalculate Quantity !
                                    Data.inventorycount[index_2] += count;
                                    Data.inventorycount[index_1] -= count;
                                }
                            }
                        }
                        else
                        {
                            // Items Are Different, Move It !
                            Data.inventoryslot[index_1] = inv_2;
                            Data.inventoryslot[index_2] = inv_1;
                        }
                    }
                    Globals.MainWindow.UpdateInventory();
                    if (Buffas.changing_weapon)
                    {
                        LogicControl.Manager();
                    }
                    if (Data.loopaction == "merge")
                    {
                        InventoryControl.MergeItems();
                    }
                }
                if (typ == 1) // Storage -> Storage
                {
                    byte   str_1   = packet.ReadUInt8();
                    byte   str_2   = packet.ReadUInt8();
                    ushort count   = packet.ReadUInt16();
                    int    index_1 = Data.storageslot.IndexOf(str_1);
                    int    index_2 = Data.storageslot.IndexOf(str_2);
                    if (index_2 == -1)
                    {
                        // No item, Moving !
                        Data.storageslot[index_1] = str_2;
                    }
                    else
                    {
                        //The item exist !
                        if (Data.storagetype[index_1] == Data.storagetype[index_2])
                        {
                            // Items Are Same, Merge It !
                            if (Data.storagecount[index_2] == Items_Info.items_maxlist[Items_Info.itemstypelist.IndexOf(Data.storagetype[index_2])])
                            {
                                // Items Are Maxed, Move It !
                                Data.storageslot[index_1] = str_2;
                                Data.storageslot[index_2] = str_1;
                            }
                            else
                            {
                                // Items Are Same, Merge It !
                                if (Data.storagecount[index_1] == count)
                                {
                                    // Merged Everything, Delete The First Item !
                                    Data.storagecount[index_2] += count;
                                    string name = Items_Info.itemsnamelist[Items_Info.itemstypelist.IndexOf(Data.storagetype[index_1])];
                                    //Globals.MainWindow.storage_list.Items.Remove(name);

                                    Data.storageid.RemoveAt(index_1);
                                    Data.storagetype.RemoveAt(index_1);
                                    Data.storagecount.RemoveAt(index_1);
                                    Data.storageslot.RemoveAt(index_1);
                                    Data.storagedurability.RemoveAt(index_1);
                                    Data.storagelevel.RemoveAt(index_1);
                                    Data.storagename.RemoveAt(index_1);
                                }
                                else
                                {
                                    // Merged Not Everything, Recalculate Quantity !
                                    Data.storagecount[index_2] += count;
                                    Data.storagecount[index_1] -= count;
                                }
                            }
                        }
                        else
                        {
                            // Items Are Different, Move It !
                            Data.storageslot[index_1] = str_2;
                            Data.storageslot[index_2] = str_1;
                        }
                    }
                }
                if (typ == 2) // From INV to STR
                {
                    byte slot_inv = packet.ReadUInt8();
                    byte slot_bnk = packet.ReadUInt8();
                    int  index    = Data.inventoryslot.IndexOf(slot_inv);
                    Data.storageid.Add(Data.inventoryid[index]);
                    Data.storagetype.Add(Data.inventorytype[index]);
                    Data.storageslot.Add(slot_bnk);
                    Data.storagecount.Add(Data.inventorycount[index]);
                    Data.storagedurability.Add(Data.inventorydurability[index]);
                    Data.storagelevel.Add(Data.inventorylevel[index]);
                    Data.storagename.Add(Data.inventoryname[index]);
                    Data.strmaxdurability.Add(Data.maxdurability[index]);

                    Data.inventoryid.RemoveAt(index);
                    Data.inventorytype.RemoveAt(index);
                    Data.inventoryslot.RemoveAt(index);
                    Data.inventorycount.RemoveAt(index);
                    Data.inventorydurability.RemoveAt(index);
                    Data.inventorylevel.RemoveAt(index);
                    Data.inventoryname.RemoveAt(index);
                    Data.maxdurability.RemoveAt(index);

                    Globals.MainWindow.UpdateInventory();
                    //Globals.MainWindow.storage_list.Items.Clear();
                    for (int i = 0; i < Data.storageid.Count; i++)
                    {
                        uint   id   = Data.storageid[i];
                        string name = Items_Info.itemsnamelist[Items_Info.itemsidlist.IndexOf(id)];
                        //Globals.MainWindow.storage_list.Items.Add(name);
                    }
                    ItemsCount.CountManager();
                    StorageControl.StorageManager(Spawns.NPCID[Spawns.NPCType.IndexOf(Data.selectednpctype)]);
                }
                if (typ == 3) // From STR to INV
                {
                    byte slot_bnk = packet.ReadUInt8();
                    byte slot_inv = packet.ReadUInt8();
                    int  index    = Data.storageslot.IndexOf(slot_bnk);

                    Data.inventoryid.Add(Data.storageid[index]);
                    Data.inventorytype.Add(Data.storagetype[index]);
                    Data.inventoryslot.Add(slot_inv);
                    Data.inventorycount.Add(Data.storagecount[index]);
                    Data.inventorydurability.Add(Data.storagedurability[index]);
                    Data.inventorylevel.Add(Data.storagelevel[index]);
                    Data.inventoryname.Add(Data.storagename[index]);
                    Data.maxdurability.Add(Data.strmaxdurability[index]);

                    Data.storageid.RemoveAt(index);
                    Data.storagetype.RemoveAt(index);
                    Data.storageslot.RemoveAt(index);
                    Data.storagecount.RemoveAt(index);
                    Data.storagedurability.RemoveAt(index);
                    Data.storagelevel.RemoveAt(index);
                    Data.storagename.RemoveAt(index);
                    Data.strmaxdurability.RemoveAt(index);

                    Globals.MainWindow.UpdateInventory();
                    //Globals.MainWindow.storage_list.Items.Clear();
                    for (int i = 0; i < Data.storageid.Count; i++)
                    {
                        uint   id   = Data.storageid[i];
                        string name = Items_Info.itemsnamelist[Items_Info.itemsidlist.IndexOf(id)];
                        //Globals.MainWindow.storage_list.Items.Add(name);
                    }
                    ItemsCount.CountManager();
                }
                if (typ == 6) // PICKED ITEM
                {
                    byte slot = packet.ReadUInt8();
                    if (slot == 254)
                    {
                        packet.ReadUInt32();
                    }
                    else
                    {
                        packet.ReadUInt32();
                        uint   item_id = packet.ReadUInt32();
                        int    index   = Items_Info.itemsidlist.IndexOf(item_id);
                        string type    = Items_Info.itemstypelist[index];
                        if (type.StartsWith("ITEM_CH") || type.StartsWith("ITEM_EU"))
                        {
                            byte item_plus = packet.ReadUInt8();
                            packet.ReadUInt64();
                            uint durability = packet.ReadUInt32();
                            byte blueamm    = packet.ReadUInt8();
                            for (int i = 0; i < blueamm; i++)
                            {
                                packet.ReadUInt8();
                                packet.ReadUInt16();
                                packet.ReadUInt32();
                                packet.ReadUInt8();
                            }
                            Data.inventoryid.Add(item_id);
                            Data.inventorytype.Add(type);
                            Data.inventoryslot.Add(slot);
                            Data.inventorycount.Add(1);
                            Data.inventorydurability.Add(durability);
                            Data.inventorylevel.Add(Items_Info.itemslevellist[index]);
                            Data.inventoryname.Add(Items_Info.itemsnamelist[index]);
                            Data.maxdurability.Add(Items_Info.itemsdurabilitylist[index]);
                            Globals.MainWindow.UpdateInventory();
                        }
                        else
                        {
                            ushort count   = packet.ReadUInt16();
                            int    indexas = Data.inventoryslot.IndexOf(slot);
                            if (indexas != -1)
                            {
                                Data.inventorycount[indexas] = count;
                            }
                            else
                            {
                                Data.inventoryid.Add(item_id);
                                Data.inventorytype.Add(type);
                                Data.inventoryslot.Add(slot);
                                Data.inventorydurability.Add(0);
                                Data.inventorycount.Add(count);
                                Data.inventorylevel.Add(Items_Info.itemslevellist[index]);
                                Data.inventoryname.Add(Items_Info.itemsnamelist[index]);
                                Data.maxdurability.Add(Items_Info.itemsdurabilitylist[index]);

                                Globals.MainWindow.UpdateInventory();
                            }
                            ItemsCount.CountManager();
                        }
                    }
                }
                if (typ == 7)
                {
                    byte slot  = packet.ReadUInt8();
                    int  index = Data.inventoryslot.IndexOf(slot);
                    Data.inventoryid.RemoveAt(index);
                    Data.inventorytype.RemoveAt(index);
                    Data.inventoryslot.RemoveAt(index);
                    Data.inventorycount.RemoveAt(index);
                    Data.inventorydurability.RemoveAt(index);
                    Data.inventorylevel.RemoveAt(index);
                    Data.inventoryname.RemoveAt(index);
                    Data.maxdurability.RemoveAt(index);

                    Globals.MainWindow.UpdateInventory();
                    ItemsCount.CountManager();
                }
                if (typ == 8) // Shop => Inventory
                {
                    byte tab   = packet.ReadUInt8();
                    byte slot  = packet.ReadUInt8();
                    byte count = packet.ReadUInt8();
                    #region Finding Item Info
                    uint item_id = 0;
                    for (int i = 0; i < Data.ShopTabData.Length; i++)
                    {
                        if (Data.ShopTabData[i].StoreName.Replace("STORE_", "NPC_") == Data.selectednpctype)
                        {
                            item_id = Items_Info.itemsidlist[Items_Info.itemstypelist.IndexOf(Data.ShopTabData[i].Tab[tab].ItemType[slot])];
                            break;
                        }
                    }
                    string item_type = Items_Info.itemstypelist[Items_Info.itemsidlist.IndexOf(item_id)];
                    #endregion
                    if (count == 1)
                    {
                        byte   inv_slot  = packet.ReadUInt8();
                        ushort inv_count = packet.ReadUInt16();

                        Packet du = new Packet((ushort)WorldServerOpcodes.SERVER_OPCODES.SERVER_INVENTORYMOVEMENT);
                        du.WriteUInt8(1);
                        du.WriteUInt8(6);
                        du.WriteUInt8(inv_slot);
                        du.WriteUInt32(0);
                        du.WriteUInt32(item_id);
                        if (item_type.StartsWith("ITEM_CH") == false && item_type.StartsWith("ITEM_EU") == false)
                        {
                            du.WriteUInt16(inv_count);
                        }
                        else
                        {
                            du.WriteUInt8(0);
                            du.WriteUInt64(0);
                            du.WriteUInt32(Items_Info.itemsdurabilitylist[Items_Info.itemsidlist.IndexOf(item_id)]);
                            du.WriteUInt8(0);
                            du.WriteUInt16(1);
                            du.WriteUInt16(2);
                        }
                        Proxy.ag_local_security.Send(du);

                        Data.inventoryid.Add(item_id);
                        Data.inventorytype.Add(item_type);
                        Data.inventoryslot.Add(inv_slot);
                        Data.inventorycount.Add(inv_count);
                        Data.inventorydurability.Add(0);
                        Data.inventorylevel.Add(Items_Info.itemslevellist[Items_Info.itemsidlist.IndexOf(item_id)]);
                        Data.inventoryname.Add(Items_Info.itemsnamelist[Items_Info.itemsidlist.IndexOf(item_id)]);
                        Data.maxdurability.Add(Items_Info.itemsdurabilitylist[Items_Info.itemsidlist.IndexOf(item_id)]);
                    }
                    else
                    {
                        for (int i = 0; i < count; i++)
                        {
                            byte inv_slot = packet.ReadUInt8();

                            Packet du = new Packet((ushort)WorldServerOpcodes.SERVER_OPCODES.SERVER_INVENTORYMOVEMENT);
                            du.WriteUInt8(0x01);
                            du.WriteUInt8(0x06);
                            du.WriteUInt8(inv_slot);
                            du.WriteUInt32(0x00000000);
                            du.WriteUInt32(item_id);
                            if (item_type.StartsWith("ITEM_CH") == false && item_type.StartsWith("ITEM_EU") == false)
                            {
                                du.WriteUInt16(1);
                            }
                            else
                            {
                                du.WriteUInt8(0x00);
                                du.WriteUInt64(0x0000000000000000);
                                du.WriteUInt32(Items_Info.itemsdurabilitylist[Items_Info.itemsidlist.IndexOf(item_id)]);
                                du.WriteUInt8(0x00);
                                du.WriteUInt16(1);
                                du.WriteUInt16(2);
                            }
                            Proxy.ag_local_security.Send(du);

                            Data.inventoryid.Add(item_id);
                            Data.inventorytype.Add(item_type);
                            Data.inventoryslot.Add(inv_slot);
                            Data.inventorycount.Add(1);
                            Data.inventorydurability.Add(0);
                            Data.inventorylevel.Add(Items_Info.itemslevellist[Items_Info.itemsidlist.IndexOf(item_id)]);
                            Data.inventoryname.Add(Items_Info.itemsnamelist[Items_Info.itemsidlist.IndexOf(item_id)]);
                            Data.maxdurability.Add(Items_Info.itemsdurabilitylist[Items_Info.itemsidlist.IndexOf(item_id)]);
                        }
                    }
                    Globals.MainWindow.UpdateInventory();
                    ItemsCount.CountManager();
                    System.Threading.Thread.Sleep(500);
                    BuyControl.BuyManager(Spawns.NPCID[Spawns.NPCType.IndexOf(Data.selectednpctype)]);
                }
                if (typ == 9) // Inventory -> Shop
                {
                    byte   inv_slot = packet.ReadUInt8();
                    ushort count    = packet.ReadUInt16();

                    int    index      = Data.inventoryslot.IndexOf(inv_slot);
                    ushort real_count = Data.inventorycount[index];

                    if (count == real_count)
                    {
                        //Sold Everything - Delete Item
                        Data.inventoryid.RemoveAt(index);
                        Data.inventorytype.RemoveAt(index);
                        Data.inventoryslot.RemoveAt(index);
                        Data.inventorycount.RemoveAt(index);
                        Data.inventorydurability.RemoveAt(index);
                        Data.inventorylevel.RemoveAt(index);
                        Data.inventoryname.RemoveAt(index);
                        Data.maxdurability.RemoveAt(index);
                    }
                    else
                    {
                        //Reduce count of item
                        ushort new_count = (ushort)(real_count - count);
                        Data.inventorycount[index] = new_count;
                    }
                    Globals.MainWindow.UpdateInventory();
                    ItemsCount.CountManager();
                    SellControl.SellManager(Spawns.NPCID[Spawns.NPCType.IndexOf(Data.selectednpctype)]);
                }
                if (typ == 16) // From Pet Inventory To Pet Inventory
                {
                    uint   petid = packet.ReadUInt32();
                    byte   pet_1 = packet.ReadUInt8();
                    byte   pet_2 = packet.ReadUInt8();
                    ushort count = packet.ReadUInt16();

                    for (int i = 0; i < Pets.CharPets.Count; i++)
                    {
                        if (Pets.CharPets[i].UniqueID == petid)
                        {
                            if (Pets.CharPets[i].Inventory[pet_1].type == Pets.CharPets[i].Inventory[pet_2].type)
                            {
                                // Items Are Same, Merge It !
                                if (Pets.CharPets[i].Inventory[pet_2].count == Items_Info.items_maxlist[Items_Info.itemstypelist.IndexOf(Pets.CharPets[i].Inventory[pet_2].type)])
                                {
                                    // Items Are Maxed, Move It !
                                    Pets.Inventory_ inv_temp = Pets.CharPets[i].Inventory[pet_1];
                                    Pets.CharPets[i].Inventory[pet_1] = Pets.CharPets[i].Inventory[pet_2];
                                    Pets.CharPets[i].Inventory[pet_2] = inv_temp;
                                }
                                else
                                {
                                    if (Pets.CharPets[i].Inventory[pet_1].count == count)
                                    {
                                        // Merged Everything, Delete The First Item !
                                        Pets.CharPets[i].Inventory[pet_2].count += count;
                                        string name = Items_Info.itemsnamelist[Items_Info.itemstypelist.IndexOf(Pets.CharPets[i].Inventory[pet_1].type)];
                                        //Globals.MainWindow.pet_inv_list.Items.Remove(name);
                                        Pets.CharPets[i].Inventory[pet_1] = new Pets.Inventory_();
                                    }
                                    else
                                    {
                                        // Merged Not Everything, Recalculate Quantity !
                                        Pets.CharPets[i].Inventory[pet_2].count += count;
                                        Pets.CharPets[i].Inventory[pet_1].count -= count;
                                    }
                                }
                            }
                            else
                            {
                                // Items Are Different, Move It !
                                Pets.Inventory_ inv_temp = Pets.CharPets[i].Inventory[pet_1];
                                Pets.CharPets[i].Inventory[pet_1] = Pets.CharPets[i].Inventory[pet_2];
                                Pets.CharPets[i].Inventory[pet_2] = inv_temp;
                            }
                            break;
                        }
                    }
                }
                if (typ == 26) // From Pet Inventory To Inventory
                {
                    uint pet_id = packet.ReadUInt32();
                    for (int i = 0; i < Pets.CharPets.Count; i++)
                    {
                        if (pet_id == Pets.CharPets[i].UniqueID)
                        {
                            byte pet_slot = packet.ReadUInt8();
                            byte inv_slot = packet.ReadUInt8();
                            Data.inventoryid.Add(Pets.CharPets[i].Inventory[pet_slot].id);
                            Data.inventorytype.Add(Pets.CharPets[i].Inventory[pet_slot].type);
                            Data.inventoryslot.Add(inv_slot);
                            Data.inventorydurability.Add(Pets.CharPets[i].Inventory[pet_slot].durability);
                            Data.inventorycount.Add(Pets.CharPets[i].Inventory[pet_slot].count);
                            Data.inventorylevel.Add(Pets.CharPets[i].Inventory[pet_slot].level);
                            Data.inventoryname.Add(Pets.CharPets[i].Inventory[pet_slot].name);
                            Data.maxdurability.Add(Pets.CharPets[i].Inventory[pet_slot].maxdurability);
                            string name = Items_Info.itemsnamelist[Items_Info.itemstypelist.IndexOf(Pets.CharPets[i].Inventory[pet_slot].type)];
                            Globals.MainWindow.UpdateInventory();
                            //Globals.MainWindow.pet_inv_list.Items.Remove(name);
                            Pets.CharPets[i].Inventory[pet_slot] = new Pets.Inventory_();
                            break;
                        }
                    }
                }
                if (typ == 27) // From Inventory To Pet Inventory
                {
                    uint pet_id = packet.ReadUInt32();
                    for (int i = 0; i < Pets.CharPets.Count; i++)
                    {
                        if (pet_id == Pets.CharPets[i].UniqueID)
                        {
                            byte inv_slot  = packet.ReadUInt8();
                            byte pet_slot  = packet.ReadUInt8();
                            int  inv_index = Data.inventoryslot.IndexOf(inv_slot);
                            Pets.CharPets[i].Inventory[pet_slot].id            = Data.inventoryid[inv_index];
                            Pets.CharPets[i].Inventory[pet_slot].type          = Data.inventorytype[inv_index];
                            Pets.CharPets[i].Inventory[pet_slot].slot          = pet_slot;
                            Pets.CharPets[i].Inventory[pet_slot].durability    = Data.inventorydurability[inv_index];
                            Pets.CharPets[i].Inventory[pet_slot].count         = Data.inventorycount[inv_index];
                            Pets.CharPets[i].Inventory[pet_slot].level         = Data.inventorylevel[inv_index];
                            Pets.CharPets[i].Inventory[pet_slot].name          = Data.inventoryname[inv_index];
                            Pets.CharPets[i].Inventory[pet_slot].maxdurability = Data.maxdurability[inv_index];
                            //Globals.MainWindow.pet_inv_list.Items.Add(Items_Info.itemsnamelist[Items_Info.itemstypelist.IndexOf(Data.inventorytype[inv_index])]);
                            Data.inventoryid.RemoveAt(inv_index);
                            Data.inventorytype.RemoveAt(inv_index);
                            Data.inventorycount.RemoveAt(inv_index);
                            Data.inventorydurability.RemoveAt(inv_index);
                            Data.inventoryslot.RemoveAt(inv_index);
                            Data.inventorylevel.RemoveAt(inv_index);
                            Data.inventoryname.RemoveAt(inv_index);
                            Data.maxdurability.RemoveAt(inv_index);

                            Globals.MainWindow.UpdateInventory();
                            break;
                        }
                    }
                }
                if (typ != 8)
                {
                    Proxy.ag_local_security.Send(vienas);
                }
            }
            if (check == 2)
            {
                byte check1 = packet.ReadUInt8();
                switch (check1)
                {
                case 0x03:
                    //Unknown
                    break;
                }
            }
        }
コード例 #3
0
ファイル: Character.cs プロジェクト: tbs005/SilkroadLeoBot
        public static void CharData(Packet packet)
        {
            try
            {
                Globals.MainWindow.UnEnable(Globals.MainWindow.characterselect);
                Globals.MainWindow.UnEnable(Globals.MainWindow.charnameselect);
                Globals.MainWindow.UnEnable(Globals.MainWindow.charlist);
                Globals.MainWindow.UnEnable(Globals.MainWindow.selectcharbutton);

                #region ResetData
                Data.inventorycount.Clear();
                Data.inventoryid.Clear();
                Data.inventoryslot.Clear();
                Data.inventorytype.Clear();
                Data.inventorydurability.Clear();
                Data.inventorylevel.Clear();
                Data.inventoryname.Clear();
                Data.maxdurability.Clear();

                Data.storageid.Clear();
                Data.storagetype.Clear();
                Data.storagecount.Clear();
                Data.storageslot.Clear();
                Data.storagedurability.Clear();
                Data.storagelevel.Clear();
                Data.storagename.Clear();

                Skill.Skills.Clear();

                Data.char_horseid  = 0;
                Data.storageopened = 0;
                #endregion

                #region Main
                packet.ReadUInt32();
                Character.RefObjID = packet.ReadUInt32();
                Character.Scale    = packet.ReadUInt8();
                Character.Level    = packet.ReadUInt8();
                Character.MaxLevel = packet.ReadUInt8();
                int maxlvl = (int)Character.Level - 1;
                Character.ExpMax           = Convert.ToUInt64(Character.explist[maxlvl]);
                Character.ExpOffset        = packet.ReadUInt64();
                Character.SExpOffset       = packet.ReadUInt32();
                Character.Gold             = packet.ReadUInt64();
                Character.SP               = packet.ReadUInt32();
                Character.RemainStatPoint  = packet.ReadUInt16();
                Character.BerserkLevel     = packet.ReadUInt8();
                Character.GatheredExpPoint = packet.ReadUInt32();
                Character.CurrentHP        = packet.ReadUInt32();
                Character.CurrentMP        = packet.ReadUInt32();
                Character.AutoInvestExp    = packet.ReadUInt8();
                Character.DailyPK          = packet.ReadUInt8();
                Character.TotalPK          = packet.ReadUInt16();
                Character.PKPenaltyPoint   = packet.ReadUInt32();
                packet.ReadUInt8();
                Globals.MainWindow.UpdateBar();
                Globals.MainWindow.SetText(Globals.MainWindow.level, Convert.ToString(Level));
                Globals.MainWindow.SetText(Globals.MainWindow.gold, Convert.ToString(Character.Gold));
                Globals.MainWindow.SetText(Globals.MainWindow.berserklevel, String.Format("{0}/5", Character.BerserkLevel));
                Globals.MainWindow.SetText(Globals.MainWindow.currentsp, Convert.ToString(Character.SP));
                packet.ReadUInt8();
                #endregion

                #region Items
                Character.InventorySize       = packet.ReadUInt8();
                Character.InventoryItemsCount = packet.ReadUInt8();
                for (int i = 0; i < Character.InventoryItemsCount; i++)
                {
                    byte ItemSlot     = packet.ReadUInt8();
                    uint ItemRentType = packet.ReadUInt32();
                    switch (ItemRentType)
                    {
                    case 1:
                        packet.ReadUInt16();
                        packet.ReadUInt32();
                        packet.ReadUInt32();
                        break;

                    case 2:
                        packet.ReadUInt16();
                        packet.ReadUInt16();
                        packet.ReadUInt32();
                        break;

                    case 3:
                        packet.ReadUInt16();
                        packet.ReadUInt32();
                        packet.ReadUInt32();
                        packet.ReadUInt16();
                        packet.ReadUInt32();
                        break;
                    }

                    uint   ItemRefItemID = packet.ReadUInt32();
                    int    index         = Items_Info.itemsidlist.IndexOf(ItemRefItemID);
                    string type          = Items_Info.itemstypelist[index];
                    string name          = Items_Info.itemsnamelist[index];
                    Data.inventoryname.Add(name);
                    Data.inventoryslot.Add(ItemSlot);
                    Data.inventorytype.Add(type);
                    Data.inventorylevel.Add(Items_Info.itemslevellist[index]);
                    Data.maxdurability.Add(Items_Info.itemsdurabilitylist[index]);
                    Data.inventoryid.Add(ItemRefItemID);
                    if (type.StartsWith("ITEM_CH") || type.StartsWith("ITEM_EU") || type.StartsWith("ITEM_MALL_AVATAR") || type.StartsWith("ITEM_ETC_E060529_GOLDDRAGONFLAG") || type.StartsWith("ITEM_EVENT_CH") || type.StartsWith("ITEM_EVENT_EU") || type.StartsWith("ITEM_EVENT_AVATAR_W_NASRUN") || type.StartsWith("ITEM_EVENT_AVATAR_M_NASRUN"))
                    {
                        byte  OptLevel   = packet.ReadUInt8();
                        ulong Variance   = packet.ReadUInt64();
                        uint  Durability = packet.ReadUInt32();
                        Data.inventorydurability.Add(Durability);
                        byte MagParamNum = packet.ReadUInt8();
                        for (int k = 0; k < MagParamNum; k++)
                        {
                            uint MagParamType  = packet.ReadUInt32();
                            uint MagParamValue = packet.ReadUInt32();
                        }
                        byte OptType  = packet.ReadUInt8();
                        byte OptCount = packet.ReadUInt8(); //1 => Socket
                        for (int l = 0; l < OptCount; l++)
                        {
                            byte OptionSlot    = packet.ReadUInt8();
                            uint OptionID      = packet.ReadUInt32();
                            uint OptionnParam1 = packet.ReadUInt32(); //=> Reference to Socket
                        }
                        byte OptType1  = packet.ReadUInt8();          //2 => Advanced Elixir
                        byte OptCount1 = packet.ReadUInt8();
                        for (int m = 0; m < OptCount1; m++)
                        {
                            byte OptionSlot1    = packet.ReadUInt8();
                            uint OptionID1      = packet.ReadUInt32();
                            uint OptionOptValue = packet.ReadUInt32(); //=> Advanced elixir in effect
                        }
                        Data.inventorycount.Add(1);
                    }
                    else if (((Data.Types.attack_spawn_types.IndexOf(type)) != -1) || (Data.Types.attack_types.IndexOf(type) != -1))
                    {
                        byte Status = packet.ReadUInt8(); //1 =>  Unsumonned, 2 => Summonned, 3 => Alive, 4 => Dead
                        if (Status == 2 || Status == 3 || Status == 4)
                        {
                            uint   PetID   = packet.ReadUInt32();
                            string PetName = packet.ReadAscii();
                            packet.ReadUInt8();
                        }
                        Data.inventorycount.Add(1);
                        Data.inventorydurability.Add(0);
                    }
                    else if (Data.Types.grabpet_spawn_types.IndexOf(type) != -1 || Data.Types.grab_types.IndexOf(type) != -1)
                    {
                        byte Status = packet.ReadUInt8(); //1 =>  Unsumonned, 2 => Summonned, 3 => Alive, 4 => Dead
                        if (Status == 2 || Status == 3 || Status == 4)
                        {
                            uint   PetID   = packet.ReadUInt32();
                            string PetName = packet.ReadAscii();
                            uint   SecondsToRentEndTime = packet.ReadUInt32();
                            packet.ReadUInt8();
                        }
                        Data.inventorycount.Add(1);
                        Data.inventorydurability.Add(0);
                    }
                    else if (type == "ITEM_ETC_TRANS_MONSTER")
                    {
                        packet.ReadUInt32();
                        Data.inventorycount.Add(1);
                        Data.inventorydurability.Add(0);
                    }
                    else if (type.Contains("ITEM_ETC_ARCHEMY_ATTRSTONE") || type.Contains("ITEM_ETC_ARCHEMY_MAGICSTONE"))
                    {
                        ushort StoneStackCount = packet.ReadUInt16();
                        if (type.Contains("ITEM_ETC_ARCHEMY_MAGICSTONE_LUCK") == false)
                        {
                            byte AttributeAssimilationProbability = packet.ReadUInt8();
                        }
                        Data.inventorycount.Add(StoneStackCount);
                        Data.inventorydurability.Add(0);
                    }
                    else if (type.StartsWith("ITEM_MALL_MAGIC_CUBE"))
                    {
                        uint StoredItemCount = packet.ReadUInt32();
                        Data.inventorycount.Add(1);
                        Data.inventorydurability.Add(0);
                    }
                    else if (type.Contains("ITEM_MALL_GACHA_CARD_WIN") || type.Contains("ITEM_MALL_GACHA_CARD_LOSE"))
                    {
                        ushort CouponStackCount  = packet.ReadUInt16();
                        byte   CouponMagParamNum = packet.ReadUInt8();
                        for (int n = 0; n < CouponMagParamNum; n++)
                        {
                            ulong CouponMagParamNumValue = packet.ReadUInt64();
                        }
                        Data.inventorycount.Add(CouponStackCount);
                        Data.inventorydurability.Add(0);
                    }
                    else
                    {
                        ushort ItemStackCount = packet.ReadUInt16();
                        Data.inventorycount.Add(ItemStackCount);
                        Data.inventorydurability.Add(0);
                    }
                }
                ItemsCount.CountManager();

                Character.AvatarInventorySize      = packet.ReadUInt8();
                Character.AvatarInventoryItemCount = packet.ReadUInt8();
                for (int i = 0; i < Character.AvatarInventoryItemCount; i++)
                {
                    byte AvatarSlot = packet.ReadUInt8(); //Slot
                    packet.ReadUInt32();
                    uint   AvatarID = packet.ReadUInt32();
                    int    index    = Items_Info.itemsidlist.IndexOf(AvatarID);
                    string type     = Items_Info.itemstypelist[index];
                    string name     = Items_Info.itemsnamelist[index];
                    byte   ItemPlus = packet.ReadUInt8();
                    packet.ReadUInt64();
                    packet.ReadUInt32();
                    byte AvatarMagParamNum = packet.ReadUInt8();
                    for (int o = 0; o < AvatarMagParamNum; o++)
                    {
                        packet.ReadUInt32();
                        packet.ReadUInt32();
                    }
                    packet.ReadUInt32();
                }
                #endregion

                #region MasteryFlag
                packet.ReadUInt8();
                Character.MasteryFlag = packet.ReadUInt8(); //0 = done, 1 = mastery
                while (MasteryFlag == 1)
                {
                    uint MasteryID    = packet.ReadUInt32();
                    byte MasteryLevel = packet.ReadUInt8();

                    MasteryFlag = packet.ReadUInt8(); //0 = done, 1 = mastery
                }
                packet.ReadUInt8();

                Character.SkillFlag = packet.ReadUInt8(); //0 = done, 1 = mastery
                while (SkillFlag == 1)
                {
                    uint SkillID     = packet.ReadUInt32();
                    byte SkillEnable = packet.ReadUInt8();
                    SkillFlag = packet.ReadUInt8(); //0 = done, 1 = mastery
                    int index = Skills_Info.skillsidlist.IndexOf(SkillID);
                    System.Timers.Timer Timer = new System.Timers.Timer();
                    Skill NewSkill            = new Skill(SkillID, Skills_Info.skillsnamelist[index], Skills_Info.skillstypelist[index], Skills_Info.skillslevellist[index],
                                                          Skills_Info.skillbuffcheck[index], 0, Skills_Info.skillscasttimelist[index],
                                                          Skills_Info.skillcooldownlist[index], Skills_Info.skillsmpreq[index], Skills_Info.skillbufftime[index], 0, Timer);

                    Skill.Skills.Add(NewSkill);
                }
                Globals.MainWindow.Updatehealskill();
                Globals.MainWindow.UpdateSkillList();
                #endregion

                #region SkippingQuestPart
                //Read every Byte the compare them to the UniqueID got from opcode 3020, if equal then stop, if not keep reading the ByteArray
                Packet charid = new Packet(3020);
                charid.WriteUInt32(Character.UniqueID);
                charid.Lock();
                byte idpart1 = charid.ReadUInt8();
                byte idpart2 = charid.ReadUInt8();
                byte idpart3 = charid.ReadUInt8();
                byte idpart4 = charid.ReadUInt8();
                while (true)
                {
                    if (packet.ReadUInt8() == idpart1)
                    {
                        if (packet.ReadUInt8() == idpart2)
                        {
                            if (packet.ReadUInt8() == idpart3)
                            {
                                if (packet.ReadUInt8() == idpart4)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                #endregion

                #region CharacterData
                //Unique ID here has been taken by the comparison #Skipping Quest Part
                byte  xsec   = packet.ReadUInt8();
                byte  ysec   = packet.ReadUInt8();
                float xcoord = packet.ReadSingle();
                float zcoord = packet.ReadSingle();
                float ycoord = packet.ReadSingle();
                if (ysec == 0x80)
                {
                    cave.char_incave = true;
                    cave.xsector     = xsec;
                    cave.zcoord      = zcoord;
                    cave.xcoord      = xcoord;
                }
                else
                {
                    cave.char_incave = false;
                }
                Character.X = Globals.CalculatePositionX(xsec, xcoord);
                Character.Y = Globals.CalculatePositionY(ysec, ycoord);
                string sector = (String.Format("{0:X2}{1:X2}", xsec, ysec));
                int    indexx = Character.locationsector.IndexOf(sector);
                if (indexx != -1)
                {
                    string location = Character.location[indexx];
                    PortConfigs.TrainWindow.Label(PortConfigs.TrainWindow.location, location);
                }
                Globals.MainWindow.SetText(Globals.MainWindow.xlabel, Convert.ToString(Character.X));
                Globals.MainWindow.SetText(Globals.MainWindow.ylabel, Convert.ToString(Character.Y));
                packet.ReadUInt8();
                packet.ReadUInt8();
                byte move = packet.ReadUInt8(); // Flag
                packet.ReadUInt8();             // Running
                if (move == 1)
                {
                    xsec   = packet.ReadUInt8();
                    ysec   = packet.ReadUInt8();
                    xcoord = packet.ReadUInt16();
                    packet.ReadUInt16();
                    ycoord = packet.ReadUInt16();
                }
                else
                {
                    packet.ReadUInt8();  // Unknown
                    packet.ReadUInt16(); // Unknwon
                }
                byte StateFlag = packet.ReadUInt8();
                packet.ReadUInt8(); //Action: 0 = None, 2 = Walking, 3 = Running, 4 = Sitting
                packet.ReadUInt8(); //Status: 0 = None, 2 = ??*GrowthPet, 3 = Invincible, 4 = Invisible
                packet.ReadUInt8();
                Character.WalkSpeed    = packet.ReadSingle();
                Character.RunSpeed     = packet.ReadSingle();
                Character.BerserkSpeed = packet.ReadSingle();
                byte ActiveBuffCount = packet.ReadUInt8();
                for (int a = 0; a < ActiveBuffCount; a++)
                {
                    uint   skillid   = packet.ReadUInt32();
                    int    buffindex = Skills_Info.skillsidlist.IndexOf(skillid);
                    string type      = Skills_Info.skillstypelist[buffindex];
                    if (type.StartsWith("SKILL_EU_CLERIC_RECOVERYA_GROUP") || type.StartsWith("SKILL_EU_BARD_BATTLAA_GUARD") || type.StartsWith("SKILL_EU_BARD_DANCEA") || type.StartsWith("SKILL_EU_BARD_SPEEDUPA_HITRATE"))
                    {
                        packet.ReadUInt8();
                    }
                }
                Character.PlayerName = packet.ReadAscii();
                Globals.MainWindow.SetText(Globals.MainWindow.charname, Character.PlayerName);
                #endregion

                #region Job
                string JobTitle        = packet.ReadAscii();
                byte   JobType         = packet.ReadUInt8(); //0 => None, 1 => Trader, 2 => Thief, 3 => Hunter
                byte   JobLevel        = packet.ReadUInt8();
                uint   JobEXP          = packet.ReadUInt8();
                uint   JobContribution = packet.ReadUInt32();
                uint   JobReward       = packet.ReadUInt32();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                packet.ReadUInt8();
                Character.AccountID = packet.ReadUInt32();
                Globals.MainWindow.SetText(Globals.MainWindow.accID, String.Format("{0:X8}", Character.AccountID));
                Globals.MainWindow.UpdateInventory();
                #endregion

                Globals.MainWindow.SetText(Globals.MainWindow.status, "Normal");
                Globals.MainWindow.SetText(Globals.MainWindow.currentexp, Convert.ToString(Character.ExpOffset));
                Globals.MainWindow.SetText(Globals.MainWindow.exppercent, String.Format("{0}%", Character.ExpOffset * 100 / ExpMax));
                Globals.MainWindow.UpdateTray();
                Globals.MainWindow.Enable(Globals.MainWindow.startbot);

                if (data_loaded == 0)
                {
                    data_loaded               = 1;
                    Data.Statistic.sp_begin   = (int)Character.SP;
                    Data.Statistic.gold_begin = (long)Character.Gold;
                    Configs.ReadConfigs();
                    System.Threading.Thread time_thread = new Thread(StartTimer);
                    time_thread.Start();
                    System.Threading.Thread time_thread1 = new Thread(StartTimer1);
                    time_thread1.Start();
                }

                for (int i = 0; i < Skill.Skills.Count; i++)
                {
                    Skill.Skills[i].index = i;
                }

                for (int i = 0; i < Globals.MainWindow.generalimbue.Items.Count; i++)
                {
                    foreach (Skill skill in Skill.Skills)
                    {
                        if (skill.Name == Globals.MainWindow.generalimbue.Items[i].ToString())
                        {
                            Skill.Imbue.Add(skill);
                            break;
                        }
                    }
                }

                for (int i = 0; i < Globals.MainWindow.partyimbue.Items.Count; i++)
                {
                    foreach (Skill skill in Skill.Skills)
                    {
                        if (skill.Name == Globals.MainWindow.partyimbue.Items[i].ToString())
                        {
                            Skill.PartyImbue.Add(skill);
                            break;
                        }
                    }
                }

                for (int i = 0; i < Globals.MainWindow.generalattack.Items.Count; i++)
                {
                    foreach (Skill skill in Skill.Skills)
                    {
                        if (skill.Name == Globals.MainWindow.generalattack.Items[i].ToString())
                        {
                            Skill.AttackSkills.Add(skill);
                            break;
                        }
                    }
                }

                for (int i = 0; i < Globals.MainWindow.partyattack.Items.Count; i++)
                {
                    foreach (Skill skill in Skill.Skills)
                    {
                        if (skill.Name == Globals.MainWindow.partyattack.Items[i].ToString())
                        {
                            Skill.PartyAttackSkills.Add(skill);
                            break;
                        }
                    }
                }

                for (int i = 0; i < Globals.MainWindow.buff.Items.Count; i++)
                {
                    foreach (Skill skill in Skill.Skills)
                    {
                        if (skill.Name == Globals.MainWindow.buff.Items[i].ToString())
                        {
                            skill.bufftype    = 1;
                            skill.BuffWaiting = 1;
                            break;
                        }
                    }
                    Buffas.buff_waiting = true;
                }

                for (int i = 0; i < Globals.MainWindow.secondbuff.Items.Count; i++)
                {
                    foreach (Skill skill in Skill.Skills)
                    {
                        if (skill.Name == Globals.MainWindow.secondbuff.Items[i].ToString())
                        {
                            skill.bufftype    = 3;
                            skill.BuffWaiting = 1;
                            break;
                        }
                    }
                    Buffas.buff_waiting = true;
                }

                if (Globals.MainWindow.Checked(Globals.MainWindow.autoparty) == true)
                {
                    Party.CreateParty();
                }

                if (Data.bot == true)
                {
                    StartLooping.Start();
                }
            }
            catch { }
        }