DestroyItem() публичный статический Метод

public static DestroyItem ( ) : byte[]
Результат byte[]
Пример #1
0
        /////////////////////////////////////////////////////////////////////////////////
        // Item destruction with alchemy
        /////////////////////////////////////////////////////////////////////////////////
        public void BreakItem()
        {
            try
            {
                //Checks before we continue
                if (Character.Stall.Stallactive || Character.Action.nAttack || Character.Action.sAttack || Character.Alchemy.working)
                {
                    return;
                }
                //Set bool
                Character.Alchemy.working = true;
                //TODO: Timer for alchemy start / end
                PacketReader reader        = new PacketReader(PacketInformation.buffer);
                byte         rondorequired = reader.Byte();
                byte         slot          = reader.Byte();
                reader.Close();


                //Get our item information (item)
                Global.slotItem item = GetItem((uint)Character.Information.CharacterID, slot, 0);

                //Get our degree information
                byte itemdegree = Data.ItemBase[item.ID].Degree;

                //First we get our elements (Same degree as weapon)
                //This should return 4 items
                //Add check rondo count if high enough.
                Character.Alchemy.Elementlist = GetDegreeElements(item.ID, Character);
                //Check if the item has any blues on it.
                if (Data.ItemBlue[item.dbID].totalblue != 0)
                {
                    Character.Alchemy.StonesList = GetStonesDegree(item.ID, Character);
                }

                //Check current free slots of the player
                byte slotcheck = GetFreeSlot();
                //If slot amount is lower then 4 return
                //Slots free must be 6 i believe because of stones (TODO: Check info official).
                if (slotcheck < 4)
                {
                    //Send error message inventory full ...
                    return;
                }
                //Player has enough slots so we continue adding the new items
                else
                {
                    //Update rondo quantity
                    Character.Information.InventorylistSlot = GetPlayerItems(Character);
                    foreach (byte e in Character.Information.InventorylistSlot)
                    {
                        //Set slotitem
                        Global.slotItem itemrondoinfo = GetItem((uint)Character.Information.CharacterID, e, 0);
                        if (itemrondoinfo.ID != 0)
                        {
                            if (Data.ItemBase[itemrondoinfo.ID].Etctype == Global.item_database.EtcType.DESTROYER_RONDO)
                            {
                                //Update amount
                                itemrondoinfo.Amount -= rondorequired;
                                ItemUpdateAmount(itemrondoinfo, Character.Information.CharacterID);
                            }
                        }
                    }
                    //Clean our list
                    Character.Information.InventorylistSlot.Clear();
                    //Remove the item used in dissembling (Query).
                    MsSQL.DeleteData("DELETE FROM char_items WHERE id='" + item.dbID + "' AND owner='" + Character.Information.CharacterID + "'");
                    //Remove the item used in dissembling (Visual).
                    ItemUpdateAmount(item, Character.Information.CharacterID);
                    //Send packet #2
                    client.Send(Packet.DestroyItem());
                    //Repeat for each element in our list.
                    foreach (int e in Character.Alchemy.Elementlist)
                    {
                        if (e != 0)
                        {
                            //TODO: Make detailed randoms
                            //Make random add count for the elements
                            //NOTE: Check what item has what element on destruction. if pk2 contains or not.
                            int elementamount = 0;

                            #region Amounts
                            if (Data.ItemBase[item.ID].Degree == 1)
                            {
                                elementamount = rnd.Next(1, 60);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 2)
                            {
                                elementamount = rnd.Next(1, 90);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 3)
                            {
                                elementamount = rnd.Next(1, 120);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 4)
                            {
                                elementamount = rnd.Next(1, 150);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 5)
                            {
                                elementamount = rnd.Next(1, 200);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 6)
                            {
                                elementamount = rnd.Next(1, 250);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 7)
                            {
                                elementamount = rnd.Next(1, 300);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 8)
                            {
                                elementamount = rnd.Next(1, 375);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 9)
                            {
                                elementamount = rnd.Next(1, 450);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 10)
                            {
                                elementamount = rnd.Next(1, 600);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 11)
                            {
                                elementamount = rnd.Next(1, 800);
                            }
                            #endregion

                            int stoneamount = 0;

                            #region Stones
                            if (Data.ItemBlue[item.dbID].totalblue != 0)
                            {
                                if (Data.ItemBlue[item.dbID].totalblue == 1)
                                {
                                    stoneamount = rnd.Next(0, 1);
                                }
                                else if (Data.ItemBlue[item.dbID].totalblue == 2)
                                {
                                    stoneamount = rnd.Next(0, 2);
                                }
                            }
                            #endregion

                            slotcheck = GetFreeSlot();
                            //Stack items todo
                            AddItem(Data.ItemBase[e].ID, 10, slotcheck, Character.Information.CharacterID, 0);
                            client.Send(Packet.GainElements(slotcheck, Data.ItemBase[e].ID, (short)elementamount));
                        }
                    }
                    //Clear created list content.
                    Character.Alchemy.Elementlist.Clear();
                }
                //Reset bool
                Character.Alchemy.working = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Alchemy error destroyer {0}", ex);
            }
        }