Beispiel #1
0
 public override void OnDoubleClick(Mobile from)
 {
     if (from.InLOS(this) && from.InRange(Location, 2))
     {
         if (m_Recipe > 0)
         {
             if (!m_MobileList.ContainsKey(from.Serial))
             {
                 Item scroll = new RecipeScroll(m_Recipe);
                 from.AddToBackpack(scroll);
                 m_MobileList.Add(from.Serial, from);
                 from.SendAsciiMessage("You put the recipe scroll in your backpack");
             }
             else
             {
                 from.SendAsciiMessage("You have already gotten the recipe!");
             }
         }
         else
         {
             from.SendAsciiMessage("This stone is not activated");
         }
     }
     else
     {
         from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
     }
 }
Beispiel #2
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (!IsChildOf(from.Backpack) && !IsLockedDown)
            {
                from.SendLocalizedMessage(1158823); // You must have the book in your backpack to add recipes to it.
                return(false);
            }
            else if (dropped is RecipeScroll)
            {
                RecipeScroll recipe = dropped as RecipeScroll;

                if (Recipes.Any(x => x.RecipeID == recipe.RecipeID))
                {
                    Recipes.ForEach(x =>
                    {
                        if (x.RecipeID == recipe.RecipeID)
                        {
                            x.Amount = x.Amount + 1;
                        }
                    });

                    InvalidateProperties();

                    from.SendLocalizedMessage(1158826); // Recipe added to the book.

                    if (from is PlayerMobile)
                    {
                        from.SendGump(new RecipeBookGump((PlayerMobile)from, this));
                    }

                    dropped.Delete();
                    return(true);
                }
                else
                {
                    from.SendLocalizedMessage(1158825); // That is not a recipe.
                    return(false);
                }
            }
            else
            {
                from.SendLocalizedMessage(1158825); // That is not a recipe.
                return(false);
            }
        }
 public override void OnDoubleClick(Mobile from)
 {
     if (from.InLOS(this) && from.InRange(Location, 2))
     {
         if (m_Recipe > 0)
         {
             if (!m_MobileList.ContainsKey(from.Serial))
             {
                 Item scroll = new RecipeScroll(m_Recipe);
                 from.AddToBackpack(scroll);
                 m_MobileList.Add(from.Serial, from);
                 from.SendAsciiMessage("You put the recipe scroll in your backpack");
             }
             else
                 from.SendAsciiMessage("You have already gotten the recipe!");
         }
         else
             from.SendAsciiMessage("This stone is not activated");
     }
     else
         from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
 }
        public override void GiveSpecialItems(List<Mobile> eligibleMobs, List<double> eligibleMobScores, double totalScores)
        {
            double currentTestValue = 0.0;
            double roll = Utility.RandomDouble() * totalScores;
            if (0.05 > Utility.RandomDouble())
            {
                for (int i = 0; i < eligibleMobScores.Count; i++)
                {
                    currentTestValue += eligibleMobScores[i];

                    if (roll > currentTestValue)
                    {
                        continue;
                    }

                    var recipescroll = new RecipeScroll(Recipe.GetRandomRecipe());
                    if (eligibleMobs[i] is PlayerMobile && eligibleMobs[i].Backpack != null)
                    {
                        eligibleMobs[i].Backpack.DropItem(recipescroll);
                        eligibleMobs[i].SendMessage(54, "You have received a recipe scroll!");
                        break;
                    }
                }
            }

            if (0.1 > Utility.RandomDouble())
            {
                for (int i = 0; i < eligibleMobScores.Count; i++)
                {
                    currentTestValue += eligibleMobScores[i];

                    if (roll > currentTestValue)
                    {
                        continue;
                    }

                    if (eligibleMobs[i] is PlayerMobile && eligibleMobs[i].Backpack != null)
                    {
                        eligibleMobs[i].Backpack.DropItem(new TitleScroll("Flummoxed!"));
                        eligibleMobs[i].SendMessage(54, "You have received a title scroll.");
                        return;
                    }
                }
            }
        }
Beispiel #5
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            int index = info.ButtonID;

            switch (index)
            {
            case 0: { m_Book.Using = false; break; }

            case 1:
            {
                from.SendGump(new RecipeScrollFilterGump(from, m_Book));
                break;
            }

            case 2:
            {
                if (m_Page > 0)
                {
                    from.SendGump(new RecipeBookGump(from, m_Book, m_Page - 1, m_List));
                }

                return;
            }

            case 3:
            {
                if (GetIndexForPage(m_Page + 1) < m_List.Count)
                {
                    from.SendGump(new RecipeBookGump(from, m_Book, m_Page + 1, m_List));
                }

                break;
            }

            default:
            {
                bool canDrop  = m_Book.IsChildOf(from.Backpack);
                bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor);

                index -= 4;

                int type = index % 2;
                index /= 2;

                if (index < 0 || index >= m_List.Count)
                {
                    break;
                }

                var recipe = m_List[index];

                if (type == 0)
                {
                    if (!m_Book.CheckAccessible(from, m_Book))
                    {
                        m_Book.SendLocalizedMessageTo(from, 1061637);         // You are not allowed to access this.
                        m_Book.Using = false;
                        break;
                    }

                    if (m_Book.IsChildOf(from.Backpack) || m_Book.IsLockedDown)
                    {
                        if (recipe.Amount == 0)
                        {
                            from.SendLocalizedMessage(1158821);         // The recipe selected is not available.
                            m_Book.Using = false;
                            break;
                        }

                        Item item = new RecipeScroll(recipe.RecipeID);

                        if (from.AddToBackpack(item))
                        {
                            m_Book.Recipes.ForEach(x =>
                                {
                                    if (x.RecipeID == recipe.RecipeID)
                                    {
                                        x.Amount = x.Amount - 1;
                                    }
                                });

                            m_Book.InvalidateProperties();

                            from.SendLocalizedMessage(1158820);         // The recipe has been placed in your backpack.

                            from.SendGump(new RecipeBookGump(from, m_Book, m_Page, null));
                        }
                        else
                        {
                            m_Book.Using = false;
                            item.Delete();
                            from.SendLocalizedMessage(1158819);         // There is not enough room in your backpack for the recipe.
                        }
                    }
                    else
                    {
                        m_Book.Using = false;
                    }
                }
                else
                {
                    if (m_Book.IsChildOf(from.Backpack))
                    {
                        from.Prompt = new SetPricePrompt(m_Book, recipe, m_Page, m_List);
                        from.SendLocalizedMessage(1062383);         // Type in a price for the deed:
                        m_Book.Using = false;
                    }
                    else if (m_Book.RootParent is PlayerVendor)
                    {
                        if (recipe.Amount > 0)
                        {
                            from.SendGump(new RecipeScrollBuyGump(from, m_Book, recipe, recipe.Price));
                        }
                        else
                        {
                            m_Book.Using = false;
                        }
                    }
                }

                break;
            }
            }
        }
Beispiel #6
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 2)
            {
                PlayerVendor pv = m_Book.RootParent as PlayerVendor;

                if (pv != null)
                {
                    int price = 0;

                    VendorItem vi = pv.GetVendorItem(m_Book);

                    if (vi != null && !vi.IsForSale)
                    {
                        price = m_Recipe.Price;
                    }

                    if (price != m_Price)
                    {
                        pv.SayTo(m_From, 1150158); // The price of the selected item has been changed from the value you confirmed. You must select and confirm the purchase again at the new price in order to buy it.
                        m_Book.Using = false;
                    }
                    else if (m_Recipe.Amount == 0 || price == 0)
                    {
                        pv.SayTo(m_From, 1158821); // The recipe selected is not available.
                        m_Book.Using = false;
                    }
                    else
                    {
                        Item item = new RecipeScroll(m_Recipe.RecipeID);

                        pv.Say(m_From.Name);

                        Container pack = m_From.Backpack;

                        if ((pack != null && pack.ConsumeTotal(typeof(Gold), price)) || Banker.Withdraw(m_From, price))
                        {
                            m_Book.Recipes.ForEach(x =>
                            {
                                if (x.RecipeID == m_Recipe.RecipeID)
                                {
                                    x.Amount = x.Amount - 1;
                                }
                            });

                            m_Book.InvalidateProperties();

                            pv.HoldGold += price;

                            if (m_From.AddToBackpack(item))
                            {
                                m_From.SendLocalizedMessage(1158820); // The recipe has been placed in your backpack.
                            }
                            else
                            {
                                pv.SayTo(m_From, 503204); // You do not have room in your backpack for this.
                            }
                            m_From.SendGump(new RecipeBookGump(m_From, m_Book));
                        }
                        else
                        {
                            pv.SayTo(m_From, 503205); // You cannot afford this item.
                            item.Delete();
                            m_Book.Using = false;
                        }
                    }
                }
                else
                {
                    m_Book.Using = false;

                    if (pv == null)
                    {
                        m_From.SendLocalizedMessage(1158821); // The recipe selected is not available.
                    }
                    else
                    {
                        pv.SayTo(m_From, 1158821); // The recipe selected is not available.
                    }
                }
            }
            else
            {
                m_Book.Using = false;
                m_From.SendLocalizedMessage(503207); // Cancelled purchase.
            }
        }
        public virtual void GiveRecipe(List<Mobile> eligibleMobs, List<double> eligibleMobScores, double totalScores)
        {
            double currentTestValue = 0.0;
            double roll = Utility.RandomDouble() * totalScores;

            for (int i = 0; i < eligibleMobScores.Count; i++)
            {
                currentTestValue += eligibleMobScores[i];

                if (roll > currentTestValue)
                {
                    continue;
                }

                var recipescroll = new RecipeScroll(Recipe.GetRandomRecipe());
                if (eligibleMobs[i] is PlayerMobile && eligibleMobs[i].Backpack != null)
                {
                    eligibleMobs[i].Backpack.DropItem(recipescroll);
                    eligibleMobs[i].SendMessage(54, "You have received a recipe scroll!");
                    return;
                }
            }
        }
        public override void GiveSpecialItems(List<Mobile> eligibleMobs, List<double> eligibleMobScores,
            double totalScores)
        {
            double currentTestValue = 0.0;
            double roll = Utility.RandomDouble() * totalScores;
            if (0.05 > Utility.RandomDouble())
            {
                for (int i = 0; i < eligibleMobScores.Count; i++)
                {
                    currentTestValue += eligibleMobScores[i];

                    if (roll > currentTestValue)
                    {
                        continue;
                    }

                    var recipescroll = new RecipeScroll(Recipe.GetRandomRecipe());
                    if (eligibleMobs[i] is PlayerMobile && eligibleMobs[i].Backpack != null)
                    {
                        eligibleMobs[i].Backpack.DropItem(recipescroll);
                        eligibleMobs[i].SendMessage(54, "You have received a recipe scroll!");
                        break;
                    }
                }
            }

            if (0.1 > Utility.RandomDouble())
            {
                for (int i = 0; i < eligibleMobScores.Count; i++)
                {
                    currentTestValue += eligibleMobScores[i];

                    if (roll > currentTestValue)
                    {
                        continue;
                    }

                    if (eligibleMobs[i] is PlayerMobile && eligibleMobs[i].Backpack != null)
                    {
                        eligibleMobs[i].Backpack.DropItem(new TitleScroll("Locked and Loaded"));
                        eligibleMobs[i].SendMessage(54, "You have received a title scroll.");
                        break;
                    }
                }
            }

            if (0.05 > Utility.RandomDouble())
            {
                for (int i = 0; i < eligibleMobScores.Count; i++)
                {
                    currentTestValue += eligibleMobScores[i];

                    if (roll > currentTestValue)
                    {
                        continue;
                    }

                    if (eligibleMobs[i] is PlayerMobile && eligibleMobs[i].Backpack != null)
                    {
                        eligibleMobs[i].Backpack.DropItem(new LeatherGloves()
                        {
                            Name = "Locke's Gloves",
                            Hue = 4,
                            Identified = true,
                            Slayer = SlayerName.Silver,
                            LootType = LootType.Blessed
                        });
                        eligibleMobs[i].SendMessage(54, "You have received a pair of Locke Cole's gloves!");
                        return;
                    }
                }
            }

        }
Beispiel #9
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int index = info.ButtonID;

            switch (index)
            {
            case 0: { break; }

            case 1:
            {
                m_From.SendGump(new RecipeScrollFilterGump(m_From, m_Book));
                break;
            }

            case 2:
            {
                if (m_Page > 0)
                {
                    m_From.SendGump(new RecipeBookGump(m_From, m_Book, m_Page - 1, m_List));
                }

                return;
            }

            case 3:
            {
                if (GetIndexForPage(m_Page + 1) < m_List.Count)
                {
                    m_From.SendGump(new RecipeBookGump(m_From, m_Book, m_Page + 1, m_List));
                }

                break;
            }

            default:
            {
                bool canDrop  = m_Book.IsChildOf(m_From.Backpack);
                bool canPrice = canDrop || (m_Book.RootParent is PlayerVendor);

                index -= 4;

                int type = index % 2;
                index /= 2;

                if (index < 0 || index >= m_List.Count)
                {
                    break;
                }

                var recipe = m_List[index];

                if (type == 0)
                {
                    if (m_Book.IsChildOf(m_From.Backpack))
                    {
                        if (recipe.Amount == 0)
                        {
                            m_From.SendLocalizedMessage(1158821);         // The recipe selected is not available.
                            break;
                        }

                        Item item = new RecipeScroll(recipe.RecipeID);

                        if (m_From.AddToBackpack(item))
                        {
                            m_Book.Recipes.ForEach(x =>
                                {
                                    if (x.RecipeID == recipe.RecipeID)
                                    {
                                        x.Amount = x.Amount - 1;
                                    }
                                });

                            m_Book.InvalidateProperties();

                            m_From.SendLocalizedMessage(1158820);         // The recipe has been placed in your backpack.

                            m_From.SendGump(new RecipeBookGump(m_From, m_Book, m_Page, null));
                        }
                        else
                        {
                            item.Delete();
                            m_From.SendLocalizedMessage(1158819);         // There is not enough room in your backpack for the recipe.
                        }
                    }
                }
                else
                {
                    if (m_Book.IsChildOf(m_From.Backpack))
                    {
                        m_From.Prompt = new SetPricePrompt(m_Book, recipe, m_Page, m_List);
                        m_From.SendLocalizedMessage(1062383);         // Type in a price for the deed:
                    }
                    else if (m_Book.RootParent is PlayerVendor)
                    {
                        PlayerVendor pv = (PlayerVendor)m_Book.RootParent;

                        VendorItem vi = pv.GetVendorItem(m_Book);

                        int price = 0;

                        if (vi != null && !vi.IsForSale)
                        {
                            price = recipe.Price;
                        }

                        if (price == 0)
                        {
                            m_From.SendLocalizedMessage(1062382);
                        }
                        else
                        {
                            m_From.SendGump(new RecipeScrollBuyGump(m_From, m_Book, recipe, price));
                        }
                    }
                }

                break;
            }
            }
        }