public void RarifyItem(ClientSession Session, RarifyMode mode, RarifyProtection protection, bool isCommand = false)
        {
            double raren2 = 80;
            double raren1 = 70;
            double rare0  = 60;
            double rare1  = 40;
            double rare2  = 30;
            double rare3  = 15;
            double rare4  = 10;
            double rare5  = 5;
            double rare6  = 2;
            double rare7  = 1;

            // double rare8 = 0; //disabled for now
            double reducedchancefactor = 1.1;

            // short itempricevnum = 0;
            short  goldprice          = 500;
            double reducedpricefactor = 0.5;

            byte cella      = 5;
            int  cellaVnum  = 1014;
            int  scrollVnum = 1218;

            if (protection == RarifyProtection.RedAmulet)
            {
                raren2 = raren1 * reducedchancefactor;
                raren1 = raren1 * reducedchancefactor;
                rare0  = rare0 * reducedchancefactor;
                rare1  = rare1 * reducedchancefactor;
                rare2  = rare2 * reducedchancefactor;
                rare3  = rare3 * reducedchancefactor;
                rare4  = rare4 * reducedchancefactor;
                rare5  = rare5 * reducedchancefactor;
                rare6  = rare6 * reducedchancefactor;
                rare7  = rare7 * reducedchancefactor;

                // rare8 = rare8 * reducedchancefactor;
            }
            switch (mode)
            {
            case RarifyMode.Free:
                break;

            case RarifyMode.Reduced:

                // TODO: Reduced Item Amount
                if (Session.Character.Gold < goldprice * reducedpricefactor)
                {
                    return;
                }
                Session.Character.Gold = Session.Character.Gold - (long)(goldprice * reducedpricefactor);
                if (Session.Character.InventoryList.CountItem(cellaVnum) < cella * reducedpricefactor)
                {
                    return;
                }
                Session.Character.InventoryList.RemoveItemAmount(cellaVnum, (int)(cella * reducedpricefactor));
                Session.SendPacket(Session.Character.GenerateGold());
                break;

            case RarifyMode.Normal:

                // TODO: Normal Item Amount
                if (Session.Character.Gold < goldprice)
                {
                    return;
                }
                Session.Character.Gold = Session.Character.Gold - goldprice;
                if (Session.Character.InventoryList.CountItem(cellaVnum) < cella)
                {
                    return;
                }
                Session.Character.InventoryList.RemoveItemAmount(cellaVnum, cella);
                if (protection == RarifyProtection.Scroll && !isCommand)
                {
                    if (Session.Character.InventoryList.CountItem(scrollVnum) < 1)
                    {
                        return;
                    }
                    Session.Character.InventoryList.RemoveItemAmount(scrollVnum);
                    Session.SendPacket("shop_end 2");
                }
                Session.SendPacket(Session.Character.GenerateGold());
                break;
            }

            int rnd = _random.Next(0, 100);

            if (rnd <= rare7 && !(protection == RarifyProtection.Scroll && this.Rare >= 7))
            {
                if (mode != RarifyMode.Drop)
                {
                    Session.Character.NotifyRarifyResult(7);
                }

                this.Rare = 7;
                SetRarityPoint();
            }
            else if (rnd <= rare6 && !(protection == RarifyProtection.Scroll && this.Rare >= 6))
            {
                if (mode != RarifyMode.Drop)
                {
                    Session.Character.NotifyRarifyResult(6);
                }
                this.Rare = 6;
                SetRarityPoint();
            }
            else if (rnd <= rare5 && !(protection == RarifyProtection.Scroll && this.Rare >= 5))
            {
                if (mode != RarifyMode.Drop)
                {
                    Session.Character.NotifyRarifyResult(5);
                }
                this.Rare = 5;
                SetRarityPoint();
            }
            else if (rnd <= rare4 && !(protection == RarifyProtection.Scroll && this.Rare >= 4))
            {
                if (mode != RarifyMode.Drop)
                {
                    Session.Character.NotifyRarifyResult(4);
                }
                this.Rare = 4;
                SetRarityPoint();
            }
            else if (rnd <= rare3 && !(protection == RarifyProtection.Scroll && this.Rare >= 3))
            {
                if (mode != RarifyMode.Drop)
                {
                    Session.Character.NotifyRarifyResult(3);
                }
                this.Rare = 3;
                SetRarityPoint();
            }
            else if (rnd <= rare2 && !(protection == RarifyProtection.Scroll && this.Rare >= 2))
            {
                if (mode != RarifyMode.Drop)
                {
                    Session.Character.NotifyRarifyResult(2);
                }
                this.Rare = 2;
                SetRarityPoint();
            }
            else if (rnd <= rare1 && !(protection == RarifyProtection.Scroll && this.Rare >= 1))
            {
                if (mode != RarifyMode.Drop)
                {
                    Session.Character.NotifyRarifyResult(1);
                }
                this.Rare = 1;
                SetRarityPoint();
            }
            else if (rnd <= rare0 && !(protection == RarifyProtection.Scroll && this.Rare >= 0) && mode == RarifyMode.Drop && this.Item.ItemType != (byte)ItemType.Shell)
            {
                if (mode != RarifyMode.Drop)
                {
                    Session.Character.NotifyRarifyResult(0);
                }
                this.Rare = 0;
                SetRarityPoint();
            }
            else if (rnd <= raren1 && !(protection == RarifyProtection.Scroll && this.Rare >= -1) && mode == RarifyMode.Drop && this.Item.ItemType != (byte)ItemType.Shell)
            {
                if (mode != RarifyMode.Drop)
                {
                    Session.Character.NotifyRarifyResult(-1);
                }
                this.Rare = -1;
                SetRarityPoint();
            }
            else if (rnd <= raren2 && !(protection == RarifyProtection.Scroll && this.Rare >= -2) && mode == RarifyMode.Drop && this.Item.ItemType != (byte)ItemType.Shell)
            {
                if (mode != RarifyMode.Drop)
                {
                    Session.Character.NotifyRarifyResult(-2);
                }
                this.Rare = -2;
                SetRarityPoint();
            }
            else if (this.Rare == 0 && this.Item.ItemType == (byte)ItemType.Shell)
            {
                this.Rare = 1;
            }
            else
            {
                if (mode != RarifyMode.Drop)
                {
                    if (protection == RarifyProtection.BlueAmulet)
                    {
                        if (protection == RarifyProtection.BlueAmulet)
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 11));
                        }
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 0));
                    }
                    else
                    {
                        if (protection == RarifyProtection.BlueAmulet)
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 11));
                        }
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 0));
                        ServerManager.Instance.Broadcast(Session.Character.GenerateEff(3004));
                    }
                }
            }

            // don't place under else.
            if (mode != RarifyMode.Drop)
            {
                Inventory inventory = Session.Character.InventoryList.GetInventoryByItemInstanceId(this.Id);
                if (inventory != null)
                {
                    Session.SendPacket(Session.Character.GenerateInventoryAdd(this.ItemVNum, 1, inventory.Type, inventory.Slot, inventory.ItemInstance.Rare, 0, inventory.ItemInstance.Upgrade, 0));
                }
            }
        }
Esempio n. 2
0
        public void RarifyItem(ClientSession session, RarifyMode mode, RarifyProtection protection,
                               bool isCommand = false)
        {
            double       raren2              = 80;
            double       raren1              = 70;
            double       rare0               = 60;
            double       rare1               = 40;
            double       rare2               = 30;
            double       rare3               = 15;
            double       rare4               = 10;
            double       rare5               = 5;
            double       rare6               = 3;
            double       rare7               = 2;
            double       rare8               = 1;
            const short  goldprice           = 500;
            const double reducedpricefactor  = 0.5;
            const double reducedchancefactor = 1.1;
            const byte   cella               = 5;
            const int    cellaVnum           = 1014;
            const int    scrollVnum          = 1218;
            double       rnd;

            if (session != null && !session.HasCurrentMapInstance)
            {
                return;
            }
            if (mode != RarifyMode.Drop || Item.ItemType == ItemType.Shell)
            {
                raren2 = 0;
                raren1 = 0;
                rare0  = 0;
                rnd    = ServerManager.Instance.RandomNumber(0, 80);
            }
            else
            {
                rnd = ServerManager.Instance.RandomNumber(0, 1000) / 10D;
            }
            if (protection == RarifyProtection.RedAmulet)
            {
                raren2 = raren1 * reducedchancefactor;
                raren1 = raren1 * reducedchancefactor;
                rare0  = rare0 * reducedchancefactor;
                rare1  = rare1 * reducedchancefactor;
                rare2  = rare2 * reducedchancefactor;
                rare3  = rare3 * reducedchancefactor;
                rare4  = rare4 * reducedchancefactor;
                rare5  = rare5 * reducedchancefactor;
                rare6  = rare6 * reducedchancefactor;
                rare7  = rare7 * reducedchancefactor;
                rare8  = rare8 * reducedchancefactor;
            }
            if (session != null)
            {
                switch (mode)
                {
                case RarifyMode.Free:
                    break;

                case RarifyMode.Reduced:

                    // TODO: Reduced Item Amount
                    if (session.Character.Gold < (long)(goldprice * reducedpricefactor))
                    {
                        return;
                    }
                    if (session.Character.Inventory.CountItem(cellaVnum) < cella * reducedpricefactor)
                    {
                        return;
                    }
                    session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella * reducedpricefactor));
                    session.Character.Gold -= (long)(goldprice * reducedpricefactor);
                    session.SendPacket(session.Character.GenerateGold());
                    break;

                case RarifyMode.Normal:

                    // TODO: Normal Item Amount
                    if (session.Character.Gold < goldprice)
                    {
                        return;
                    }
                    if (session.Character.Inventory.CountItem(cellaVnum) < cella)
                    {
                        return;
                    }
                    if (protection == RarifyProtection.Scroll && !isCommand &&
                        session.Character.Inventory.CountItem(scrollVnum) < 1)
                    {
                        return;
                    }

                    if (protection == RarifyProtection.Scroll && !isCommand)
                    {
                        session.Character.Inventory.RemoveItemAmount(scrollVnum);
                        session.SendPacket("shop_end 2");
                    }
                    session.Character.Gold -= goldprice;
                    session.Character.Inventory.RemoveItemAmount(cellaVnum, cella);
                    session.SendPacket(session.Character.GenerateGold());
                    break;

                case RarifyMode.Drop:
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
                }
            }
            if (Item.IsHeroic && protection == RarifyProtection.Scroll)
            {
                if (rnd < rare8 && !(protection == RarifyProtection.Scroll && Rare >= 8))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        session?.Character.NotifyRarifyResult(8);
                    }

                    Rare = 8;
                    SetRarityPoint();
                    ItemInstance inventory = session?.Character.Inventory.GetItemInstanceById(Id);
                    if (inventory != null)
                    {
                        session.SendPacket(inventory.GenerateInventoryAdd());
                    }
                    return;
                }
            }
            if (rnd < rare7 && !(protection == RarifyProtection.Scroll && Rare >= 7))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(7);
                }

                Rare = 7;
                SetRarityPoint();
            }
            else if (rnd < rare6 && !(protection == RarifyProtection.Scroll && Rare >= 6))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(6);
                }
                Rare = 6;
                SetRarityPoint();
            }
            else if (rnd < rare5 && !(protection == RarifyProtection.Scroll && Rare >= 5))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(5);
                }
                Rare = 5;
                SetRarityPoint();
            }
            else if (rnd < rare4 && !(protection == RarifyProtection.Scroll && Rare >= 4))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(4);
                }
                Rare = 4;
                SetRarityPoint();
            }
            else if (rnd < rare3 && !(protection == RarifyProtection.Scroll && Rare >= 3))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(3);
                }
                Rare = 3;
                SetRarityPoint();
            }
            else if (rnd < rare2 && !(protection == RarifyProtection.Scroll && Rare >= 2))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(2);
                }
                Rare = 2;
                SetRarityPoint();
            }
            else if (rnd < rare1 && !(protection == RarifyProtection.Scroll && Rare >= 1))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(1);
                }
                Rare = 1;
                SetRarityPoint();
            }
            else if (rnd < rare0 && !(protection == RarifyProtection.Scroll && Rare >= 0))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(0);
                }
                Rare = 0;
                SetRarityPoint();
            }
            else if (rnd < raren1 && !(protection == RarifyProtection.Scroll && Rare >= -1))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(-1);
                }
                Rare = -1;
                SetRarityPoint();
            }
            else if (rnd < raren2 && !(protection == RarifyProtection.Scroll && Rare >= -2))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(-2);
                }
                Rare = -2;
                SetRarityPoint();
            }
            else
            {
                if (mode != RarifyMode.Drop && session != null)
                {
                    if (protection == RarifyProtection.None)
                    {
                        session.Character.DeleteItemByItemInstanceId(Id);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 11));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 0));
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 11));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 0));
                        session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                    }
                }
            }
            if (mode != RarifyMode.Drop && session != null)
            {
                ItemInstance inventory = session.Character.Inventory.GetItemInstanceById(Id);
                if (inventory != null)
                {
                    session.SendPacket(inventory.GenerateInventoryAdd());
                }
            }
        }
Esempio n. 3
0
        public void RarifyItem(ClientSession session, RarifyMode mode, RarifyProtection protection,
            bool isCommand = false)
        {
            double raren2 = 80;
            double raren1 = 70;
            double rare0 = 60;
            double rare1 = 40;
            double rare2 = 30;
            double rare3 = 15;
            double rare4 = 10;
            double rare5 = 5;
            double rare6 = 3;
            double rare7 = 2;
            double rare8 = 1;
            const short goldprice = 500;
            const double reducedpricefactor = 0.5;
            const double reducedchancefactor = 1.1;
            const byte cella = 5;
            const int cellaVnum = 1014;
            const int scrollVnum = 1218;
            int rnd;

            if (session != null && !session.HasCurrentMap)
            {
                return;
            }
            if (mode != RarifyMode.Drop || Item.ItemType == ItemType.Shell)
            {
                raren2 = 0;
                raren1 = 0;
                rare0 = 0;
                rnd = _random.Next(0, 80);
            }
            else
            {
                rnd = _random.Next(0, 100);
            }
            if (protection == RarifyProtection.RedAmulet)
            {
                raren2 = raren1 * reducedchancefactor;
                raren1 = raren1 * reducedchancefactor;
                rare0 = rare0 * reducedchancefactor;
                rare1 = rare1 * reducedchancefactor;
                rare2 = rare2 * reducedchancefactor;
                rare3 = rare3 * reducedchancefactor;
                rare4 = rare4 * reducedchancefactor;
                rare5 = rare5 * reducedchancefactor;
                rare6 = rare6 * reducedchancefactor;
                rare7 = rare7 * reducedchancefactor;
                rare8 = rare8 * reducedchancefactor;

                // rare8 = rare8 * reducedchancefactor;
            }
            if (session != null)
            {
                switch (mode)
                {
                    case RarifyMode.Free:
                        break;

                    case RarifyMode.Reduced:

                        // TODO: Reduced Item Amount
                        if (session.Character.Gold < (long)(goldprice * reducedpricefactor))
                        {
                            return;
                        }
                        if (session.Character.Inventory.CountItem(cellaVnum) < cella * reducedpricefactor)
                        {
                            return;
                        }
                        session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella * reducedpricefactor));
                        session.Character.Gold -= (long)(goldprice * reducedpricefactor);
                        session.SendPacket(session.Character.GenerateGold());
                        break;

                    case RarifyMode.Normal:

                        // TODO: Normal Item Amount
                        if (session.Character.Gold < goldprice)
                        {
                            return;
                        }
                        if (session.Character.Inventory.CountItem(cellaVnum) < cella)
                        {
                            return;
                        }
                        if (protection == RarifyProtection.Scroll && !isCommand &&
                            session.Character.Inventory.CountItem(scrollVnum) < 1)
                        {
                            return;
                        }

                        if (protection == RarifyProtection.Scroll && !isCommand)
                        {
                            session.Character.Inventory.RemoveItemAmount(scrollVnum);
                            session.SendPacket("shop_end 2");
                        }
                        session.Character.Gold -= goldprice;
                        session.Character.Inventory.RemoveItemAmount(cellaVnum, cella);
                        session.SendPacket(session.Character.GenerateGold());
                        break;
                }
            }
            if (Item.IsHeroic && protection == RarifyProtection.Scroll)
            {
                if (rnd <= rare8 && !(protection == RarifyProtection.Scroll && Rare >= 8))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        session?.Character.NotifyRarifyResult(8);
                    }

                    Rare = 8;
                    SetRarityPoint();
                    ItemInstance inventory = session?.Character.Inventory.GetItemInstanceById(Id);
                    if (inventory != null)
                    {
                        session.SendPacket(session.Character.GenerateInventoryAdd(ItemVNum, 1, inventory.Type, inventory.Slot, inventory.Rare, 0, inventory.Upgrade, 0));
                    }
                    return;
                }
            }
            if (rnd <= rare7 && !(protection == RarifyProtection.Scroll && Rare >= 7))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(7);
                }

                Rare = 7;
                SetRarityPoint();
            }
            else if (rnd <= rare6 && !(protection == RarifyProtection.Scroll && Rare >= 6))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(6);
                }
                Rare = 6;
                SetRarityPoint();
            }
            else if (rnd <= rare5 && !(protection == RarifyProtection.Scroll && Rare >= 5))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(5);
                }
                Rare = 5;
                SetRarityPoint();
            }
            else if (rnd <= rare4 && !(protection == RarifyProtection.Scroll && Rare >= 4))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(4);
                }
                Rare = 4;
                SetRarityPoint();
            }
            else if (rnd <= rare3 && !(protection == RarifyProtection.Scroll && Rare >= 3))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(3);
                }
                Rare = 3;
                SetRarityPoint();
            }
            else if (rnd <= rare2 && !(protection == RarifyProtection.Scroll && Rare >= 2))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(2);
                }
                Rare = 2;
                SetRarityPoint();
            }
            else if (rnd <= rare1 && !(protection == RarifyProtection.Scroll && Rare >= 1))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(1);
                }
                Rare = 1;
                SetRarityPoint();
            }
            else if (rnd <= rare0 && !(protection == RarifyProtection.Scroll && Rare >= 0))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(0);
                }
                Rare = 0;
                SetRarityPoint();
            }
            else if (rnd <= raren1 && !(protection == RarifyProtection.Scroll && Rare >= -1))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(-1);
                }
                Rare = -1;
                SetRarityPoint();
            }
            else if (rnd <= raren2 && !(protection == RarifyProtection.Scroll && Rare >= -2))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(-2);
                }
                Rare = -2;
                SetRarityPoint();
            }
            else
            {
                if (mode != RarifyMode.Drop && session != null)
                {
                    if (protection == RarifyProtection.None)
                    {
                        session.Character.DeleteItemByItemInstanceId(Id);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 11));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 0));
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 11));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 0));
                        session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                    }
                }
            }

            // don't place under else.
            if (mode != RarifyMode.Drop && session != null)
            {
                ItemInstance inventory = session.Character.Inventory.GetItemInstanceById(Id);
                if (inventory != null)
                {
                    session.SendPacket(session.Character.GenerateInventoryAdd(ItemVNum, 1, inventory.Type, inventory.Slot, inventory.Rare, 0, inventory.Upgrade, 0));
                }
            }
        }
Esempio n. 4
0
        public void RarifyItem(ClientSession Session, RarifyMode mode, RarifyProtection protection)
        {
            double raren2 = 80;
            double raren1 = 70;
            double rare0  = 60;
            double rare1  = 35;
            double rare2  = 25;
            double rare3  = 20;
            double rare4  = 15;
            double rare5  = 10;
            double rare6  = 5;
            double rare7  = 1;
            double rare8  = 0;
            double reducedchancefactor = 1.1;

            //short itempricevnum = 0;
            short  goldprice          = 500;
            double reducedpricefactor = 0.5;

            byte cella     = 5;
            int  cellavnum = 1014;

            if (protection == RarifyProtection.RedAmulet)
            {
                raren2 = raren1 * reducedchancefactor;
                raren1 = raren1 * reducedchancefactor;
                rare0  = rare0 * reducedchancefactor;
                rare1  = rare1 * reducedchancefactor;
                rare2  = rare2 * reducedchancefactor;
                rare3  = rare3 * reducedchancefactor;
                rare4  = rare4 * reducedchancefactor;
                rare5  = rare5 * reducedchancefactor;
                rare6  = rare6 * reducedchancefactor;
                rare7  = rare7 * reducedchancefactor;
                rare8  = rare8 * reducedchancefactor;
            }
            switch (mode)
            {
            case RarifyMode.Free:
                break;

            case RarifyMode.Reduced:
                // TODO: Reduced Item Amount
                if (Session.Character.Gold < goldprice * reducedpricefactor)
                {
                    return;
                }
                Session.Character.Gold = Session.Character.Gold - (long)(goldprice * reducedpricefactor);
                if (Session.Character.InventoryList.CountItem(cellavnum) < cella * reducedpricefactor)
                {
                    return;
                }
                Session.Character.InventoryList.RemoveItemAmount(cellavnum, (int)(cella * reducedpricefactor));
                Session.Client.SendPacket(Session.Character.GenerateGold());
                break;

            case RarifyMode.Normal:
                // TODO: Normal Item Amount
                if (Session.Character.Gold < goldprice)
                {
                    return;
                }
                Session.Character.Gold = Session.Character.Gold - goldprice;
                if (Session.Character.InventoryList.CountItem(cellavnum) < cella)
                {
                    return;
                }
                Session.Character.InventoryList.RemoveItemAmount(cellavnum, cella);
                Session.Client.SendPacket(Session.Character.GenerateGold());
                break;
            }

            Random r   = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);
            int    rnd = r.Next(0, 100);

            if (this.Item.EquipmentSlot == (byte)EquipmentType.MainWeapon || this.Item.EquipmentSlot == (byte)EquipmentType.SecondaryWeapon || this.Item.EquipmentSlot == (byte)EquipmentType.Armor)
            {
                if (rnd <= rare8 && !(protection == RarifyProtection.Scroll && this.Rare >= 8))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        Session.Character.NotiyRarifyResult(8);
                    }

                    this.Rare = 8;
                    SetRarityPoint();
                }
                if (rnd <= rare7 && !(protection == RarifyProtection.Scroll && this.Rare >= 7))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        Session.Character.NotiyRarifyResult(7);
                    }

                    this.Rare = 7;
                    SetRarityPoint();
                }
                else if (rnd <= rare6 && !(protection == RarifyProtection.Scroll && this.Rare >= 6))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        Session.Character.NotiyRarifyResult(6);
                    }
                    this.Rare = 6;
                    SetRarityPoint();
                }
                else if (rnd <= rare5 && !(protection == RarifyProtection.Scroll && this.Rare >= 5))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        Session.Character.NotiyRarifyResult(5);
                    }
                    this.Rare = 5;
                    SetRarityPoint();
                }
                else if (rnd <= rare4 && !(protection == RarifyProtection.Scroll && this.Rare >= 4))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        Session.Character.NotiyRarifyResult(4);
                    }
                    this.Rare = 4;
                    SetRarityPoint();
                }
                else if (rnd <= rare3 && !(protection == RarifyProtection.Scroll && this.Rare >= 3))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        Session.Character.NotiyRarifyResult(3);
                    }
                    this.Rare = 3;
                    SetRarityPoint();
                }
                else if (rnd <= rare2 && !(protection == RarifyProtection.Scroll && this.Rare >= 2))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        Session.Character.NotiyRarifyResult(2);
                    }
                    this.Rare = 2;
                    SetRarityPoint();
                }
                else if (rnd <= rare1 && !(protection == RarifyProtection.Scroll && this.Rare >= 1))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        Session.Character.NotiyRarifyResult(1);
                    }
                    this.Rare = 1;
                    SetRarityPoint();
                }
                else if (rnd <= rare0 && !(protection == RarifyProtection.Scroll && this.Rare >= 0) && mode == RarifyMode.Drop)
                {
                    this.Rare = 0;
                    SetRarityPoint();
                }
                else if (rnd <= raren1 && !(protection == RarifyProtection.Scroll && this.Rare >= -1) && mode == RarifyMode.Drop)
                {
                    this.Rare = -1;
                    SetRarityPoint();
                }
                else if (rnd <= raren2 && !(protection == RarifyProtection.Scroll && this.Rare >= -2) && mode == RarifyMode.Drop)
                {
                    this.Rare = -2;
                    SetRarityPoint();
                }
                else
                {
                    if (mode != RarifyMode.Drop)
                    {
                        if (protection == RarifyProtection.None)
                        {
                            Session.Character.DeleteItemByItemInstanceId(this.ItemInstanceId);
                            Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 11));
                            Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 0));
                        }
                        else
                        {
                            Session.Client.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 11));
                            Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 0));
                            ServerManager.Instance.Broadcast(Session.Character.GenerateEff(3004));
                            //Session.Character.InventoryList.LoadByItemInstance<WearableInstance>(this.ItemInstanceId).IsFixed = true;
                        }
                    }
                }
            }
        }