Beispiel #1
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == (int)Buttons.ButtonCraft)
            {
                List <ICraftableRare> craftables = RaresCraftingSystem.GetCraftables(m_Category);
                ICraftableRare        the_rare   = craftables[m_ItemIndex];
                if (!the_rare.MeetsRequiredSkillLevel_1(state.Mobile) && the_rare.MeetsRequiredSkillLevel_2(state.Mobile))
                {
                    state.Mobile.SendMessage("You are not skilled enough to create this item");
                    return;
                }

                RaresCraftingSystem.TryCreateItem(state.Mobile, the_rare);
            }
            state.Mobile.SendGump(new RaresCraftingGump(m_From, m_Category));
        }
Beispiel #2
0
        public static bool TryCreateItem(Mobile owner, ICraftableRare rare)
        {
            List <Item> to_be_consumed = new List <Item>();

            foreach (CraftableEntry ingredient in rare.GetIngredients())
            {
                int found = 0;
                foreach (Item bpitem in owner.Backpack.Items)
                {
                    if (bpitem.ItemID == ingredient.m_ItemId)
                    {
                        to_be_consumed.Add(bpitem);
                        found += bpitem.Amount;
                        if (found == ingredient.m_AmountRequired)
                        {
                            break;
                        }
                    }
                }
                if (found != ingredient.m_AmountRequired)
                {
                    owner.SendMessage(String.Format("You do not have all the ingredients in your backpack (\"{0}\")", ingredient.m_Name));
                    return(false);
                }
            }

            // have all ingredients in BP at this point

            // create the rare and try put it in the players backpack
            Item result = rare.GenerateCraftedItem();

            if (owner.Backpack.TryDropItem(owner, result, true))
            {
                owner.SendLocalizedMessage(500442);                 // You create the item and put it in your backpack.

                // delete reagents
                foreach (Item i in to_be_consumed)
                {
                    i.Delete();
                }
            }
            return(true);
        }
Beispiel #3
0
        public CraftItemGump(Mobile from, ECraftableRareCategory category, int itemidx) : base(0, 0)
        {
            this.Closable   = true;
            this.Disposable = true;
            this.Dragable   = true;
            this.Resizable  = false;

            from.CloseAllGumps();

            m_Category = category;
            List <ICraftableRare> craftables = RaresCraftingSystem.GetCraftables(m_Category);

            m_ItemIndex = Math.Min(craftables.Count - 1, Math.Max(itemidx, 0));
            m_From      = from;

            ICraftableRare the_rare = craftables[m_ItemIndex];

            this.AddPage(0);
            this.AddBackground(5, 5, 441, 361, 9200);
            this.AddBackground(13, 41, 139, 314, 9200);

            // result
            this.AddLabel(14, 16, 53, "Craftable: ");
            this.AddItem(66 + the_rare.DispOffsetX, 135 + the_rare.DispOffsetY, the_rare.GetResult().m_ItemId);

            // ingredients
            CraftableEntry[] ingredients = the_rare.GetIngredients();
            this.AddLabel(158, 16, 53, "Ingredients:");

            this.AddItem(190, 81, ingredients[0].m_ItemId);
            this.AddLabel(249, 81, 2036, String.Format("{0} : {1}", ingredients[0].m_Name, ingredients[0].m_AmountRequired));

            if (ingredients.Length > 1)
            {
                this.AddItem(190, 135, ingredients[1].m_ItemId);
                this.AddLabel(249, 135, 2036, String.Format("{0} : {1}", ingredients[1].m_Name, ingredients[1].m_AmountRequired));
            }
            if (ingredients.Length > 2)
            {
                this.AddItem(190, 189, ingredients[2].m_ItemId);
                this.AddLabel(249, 189, 2036, String.Format("{0} : {1}", ingredients[2].m_Name, ingredients[2].m_AmountRequired));
            }
            if (ingredients.Length > 3)             // TRANSFORMATION DUST!
            {
                this.AddItem(190, 275, ingredients[3].m_ItemId);
                this.AddLabel(249, 275, 2036, String.Format("{0} : {1}", ingredients[3].m_Name, ingredients[3].m_AmountRequired));
            }

            // transform
            this.AddLabel(345, 318, 2036, "Craft it");
            this.AddButton(404, 317, 4005, 4007, (int)Buttons.ButtonCraft, GumpButtonType.Reply, 0);


            // required skills
            this.AddLabel(158, 295, 53, "Skill requirements:");
            if (the_rare.m_FirstRequiredSkill.Length > 0)
            {
                int hue = the_rare.MeetsRequiredSkillLevel_1(m_From) ? 0x44: 1643;                 // green or red
                this.AddLabel(180, 318, 2036, the_rare.m_FirstRequiredSkill);
                this.AddLabel(268, 318, hue, "100.0");
            }
            if (the_rare.m_SecondRequiredSkill.Length > 0)
            {
                int hue = the_rare.MeetsRequiredSkillLevel_2(m_From) ? 0x44 : 1643;                 // green or red
                this.AddLabel(180, 336, 2036, the_rare.m_SecondRequiredSkill);
                this.AddLabel(268, 336, hue, "100.0");
            }
        }