Ejemplo n.º 1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            switch (info.ButtonID)
            {
            case 0:     // Back Button
            {
                CraftGump craftGump = new CraftGump(m_From, m_CraftSystem, m_Tool, null);
                m_From.SendGump(craftGump);
                break;
            }

            case 1:     // Make Button
            {
                if (m_CraftItem.TryCraft != null)
                {
                    m_CraftItem.TryCraft(m_From, m_CraftItem, m_Tool);
                    return;
                }

                int num = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.ItemType);

                if (num > 0)
                {
                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num));
                }
                else
                {
                    Type type = null;

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    if (context != null)
                    {
                        CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
                        int            resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                        if (resIndex > -1)
                        {
                            type = res.GetAt(resIndex).ItemType;
                        }
                    }

                    m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, type, m_Tool, m_CraftItem);
                }
                break;
            }

            case 2:                                   //Make Number
                m_From.Prompt = new MakeNumberCraftPrompt(m_From, m_CraftSystem, m_CraftItem, m_Tool);
                m_From.SendLocalizedMessage(1112576); //Please type the amount you wish to create(1 - 100): <Escape to cancel>
                break;

            case 3:     //Make Max
                AutoCraftTimer.EndTimer(m_From);
                new AutoCraftTimer(m_From, m_CraftSystem, m_CraftItem, m_Tool, 9999, TimeSpan.FromSeconds(m_CraftSystem.Delay * m_CraftSystem.MaxCraftEffect + 1.0), TimeSpan.FromSeconds(m_CraftSystem.Delay * m_CraftSystem.MaxCraftEffect + 1.0));
                break;
            }
        }
Ejemplo n.º 2
0
			public InternalTimer(
				Mobile from, CraftSystem craftSystem, CraftItem craftItem, Type typeRes, BaseTool tool, int iCountMax)
				: base(TimeSpan.Zero, TimeSpan.FromSeconds(craftSystem.Delay), iCountMax)
			{
				m_From = from;
				m_CraftItem = craftItem;
				m_iCount = 0;
				m_iCountMax = iCountMax;
				m_CraftSystem = craftSystem;
				m_TypeRes = typeRes;
				m_Tool = tool;
                m_AutoCraft = AutoCraftTimer.HasTimer(from);
			}
Ejemplo n.º 3
0
        public override void OnResponse(Mobile from, string text)
        {
            int amount = Utility.ToInt32(text);

            if (amount < 1 || amount > 100)
            {
                from.SendLocalizedMessage(1112587); // Invalid Entry.
                ResendGump();
            }
            else
            {
                AutoCraftTimer.EndTimer(from);
                new AutoCraftTimer(m_From, m_CraftSystem, m_CraftItem, m_Tool, amount, TimeSpan.FromSeconds(m_CraftSystem.Delay * m_CraftSystem.MaxCraftEffect + 1.0), TimeSpan.FromSeconds(m_CraftSystem.Delay * m_CraftSystem.MaxCraftEffect + 1.0));

                CraftContext context = m_CraftSystem.GetContext(from);

                if (context != null)
                {
                    context.MakeTotal = amount;
                }
            }
        }
Ejemplo n.º 4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID <= 0)
            {
                return; // Canceled
            }
            int buttonID = info.ButtonID - 1;
            int type     = buttonID % 7;
            int index    = buttonID / 7;

            CraftSystem   system  = this.m_CraftSystem;
            CraftGroupCol groups  = system.CraftGroups;
            CraftContext  context = system.GetContext(this.m_From);

            #region Stygian Abyss
            if (Locked)
            {
                if (type == 6 && index == 11)
                {
                    // Cancel Make
                    AutoCraftTimer.EndTimer(m_From);
                }
                return;
            }
            #endregion

            switch (type)
            {
            case 0:     // Show group
            {
                if (context == null)
                {
                    break;
                }

                if (index >= 0 && index < groups.Count)
                {
                    context.LastGroupIndex = index;
                    this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null));
                }

                break;
            }

            case 1:     // Create item
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        this.CraftItem(group.CraftItems.GetAt(index));
                    }
                }

                break;
            }

            case 2:     // Item details
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        this.m_From.SendGump(new CraftGumpItem(this.m_From, system, group.CraftItems.GetAt(index), this.m_Tool));
                    }
                }

                break;
            }

            case 3:     // Create item (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    this.CraftItem(lastTen[index]);
                }

                break;
            }

            case 4:     // Item details (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    this.m_From.SendGump(new CraftGumpItem(this.m_From, system, lastTen[index], this.m_Tool));
                }

                break;
            }

            case 5:     // Resource selected
            {
                if (this.m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes.GetAt(index);

                    if (this.m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null));
                    }
                }
                else if (this.m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes2.GetAt(index);

                    if (this.m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null));
                    }
                }

                break;
            }

            case 6:     // Misc. buttons
            {
                switch (index)
                {
                case 0:             // Resource selection
                {
                    if (system.CraftSubRes.Init)
                    {
                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null, CraftPage.PickResource));
                    }

                    break;
                }

                case 1:             // Smelt item
                {
                    if (system.Resmelt)
                    {
                        Resmelt.Do(this.m_From, system, this.m_Tool);
                    }

                    break;
                }

                case 2:             // Make last
                {
                    if (context == null)
                    {
                        break;
                    }

                    CraftItem item = context.LastMade;

                    if (item != null)
                    {
                        this.CraftItem(item);
                    }
                    else
                    {
                        this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, 1044165, this.m_Page));                 // You haven't made anything yet.
                    }
                    break;
                }

                case 3:             // Last 10
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.LastGroupIndex = 501;
                    this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null));

                    break;
                }

                case 4:             // Toggle use resource hue
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.DoNotColor = !context.DoNotColor;

                    this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, null, this.m_Page));

                    break;
                }

                case 5:             // Repair item
                {
                    if (system.Repair)
                    {
                        Repair.Do(this.m_From, system, this.m_Tool);
                    }

                    break;
                }

                case 6:             // Toggle mark option
                {
                    if (context == null || !system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case CraftMarkOption.MarkItem:
                        context.MarkOption = CraftMarkOption.DoNotMark;
                        break;

                    case CraftMarkOption.DoNotMark:
                        context.MarkOption = CraftMarkOption.PromptForMark;
                        break;

                    case CraftMarkOption.PromptForMark:
                        context.MarkOption = CraftMarkOption.MarkItem;
                        break;
                    }

                    this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, null, this.m_Page));

                    break;
                }

                case 7:             // Resource selection 2
                {
                    if (system.CraftSubRes2.Init)
                    {
                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null, CraftPage.PickResource2));
                    }

                    break;
                }

                case 8:             // Enhance item
                {
                    if (system.CanEnhance)
                    {
                        Enhance.BeginTarget(this.m_From, system, this.m_Tool);
                    }

                    break;
                }

                    #region Stygian Abyss
                case 9:             // Alter Item (Gargoyle)
                {
                    if (system.CanAlter)
                    {
                        if (Server.SkillHandlers.Imbuing.CheckSoulForge(m_From, 1, false))
                        {
                            AlterItem.BeginTarget(this.m_From, system, this.m_Tool);
                        }
                        else
                        {
                            m_From.SendLocalizedMessage(1111867);                 // You must be near a soulforge to alter an item.
                        }
                    }
                    break;
                }

                case 10:             // Quest Item/Non Quest Item toggle
                {
                    //if (context == null || !system.QuestOption)
                    //break;
                    switch (context.QuestOption)
                    {
                    case CraftQuestOption.QuestItem:
                        context.QuestOption = CraftQuestOption.NonQuestItem;
                        break;

                    case CraftQuestOption.NonQuestItem:
                        context.QuestOption = CraftQuestOption.QuestItem;
                        break;
                    }

                    this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, null, this.m_Page));

                    break;
                }

                case 11:             // Cancel Make
                {
                    AutoCraftTimer.EndTimer(m_From);
                    break;
                }
                    #endregion
                }
                break;
            }
            }
        }
Ejemplo n.º 5
0
        private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page)
            : base(40, 40)
        {
            this.m_From        = from;
            this.m_CraftSystem = craftSystem;
            this.m_Tool        = tool;
            this.m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            this.AddPage(0);

            AddBackground(0, 0, 530, 497, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 145, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 477);

            if (craftSystem.GumpTitleNumber > 0)
            {
                this.AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                this.AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);  // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER>
            AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER>

            this.AddButton(15, 442, 4017, 4019, 0, GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(50, 445, 150, 18, 1011441, LabelColor, false, false); // EXIT

            this.AddButton(115, 442, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(150, 445, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE

            // Repair option
            if (m_CraftSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM
            }
            // ****************************************

            // Mark option
            if (m_CraftSystem.MarkOption)
            {
                AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM
            }
            // ****************************************

            // Enhance option
            if (m_CraftSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM
            }
            // ****************************************

            #region SA
            // Alter option
            if (Core.SA && m_CraftSystem.CanAlter)
            {
                AddButton(270, 402, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0);
                AddHtmlLocalized(304, 405, 250, 18, 1094726, LabelColor, false, false); // ALTER ITEM (Gargoyle)
            }
            // ****************************************

            // Quest item
            if (Core.SA)
            {
                AddButton(270, 422, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 425, 150, 18, context != null && context.QuestOption == CraftQuestOption.QuestItem ? 1112534 : 1112533, LabelColor, false, false); // QUEST ITEM
            }
            // ****************************************
            #endregion

            AddButton(270, 442, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 445, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST

            #region Stygian Abyss
            int total = 1;
            int made  = 0;

            if (Locked && AutoCraftTimer.AutoCraftTable.ContainsKey(m_From))
            {
                AutoCraftTimer timer = AutoCraftTimer.AutoCraftTable[m_From];

                if (timer != null)
                {
                    total = timer.Amount;
                    made  = timer.Attempts;
                }
                else
                {
                    if (context != null)
                    {
                        total = context.MakeTotal;
                    }
                }
            }

            string args = String.Format("{0}\t{1}", made.ToString(), total.ToString());

            AddHtmlLocalized(270, 468, 150, 18, 1079443, args, LabelColor, false, false); //~1_DONE~/~2_TOTAL~ COMPLETED
            #endregion

            // Resmelt option
            if (m_CraftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM
            }
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                this.AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                this.AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                Type resourceType = craftSystem.CraftSubRes.ResType;
                //Type resourceType2 = GetAltType(resourceType);

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                    //daat99 OWLTR start - craft from storage
                    ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, resourceType);
                    if (storageCount > 0)
                    {
                        if (storageCount < int.MaxValue && storageCount + (ulong)resourceCount < int.MaxValue)
                        {
                            resourceCount += (int)storageCount;
                        }
                        else
                        {
                            resourceCount = int.MaxValue;
                        }
                    }
                    //daat99 OWLTR end - craft from storage
                }

                this.AddButton(15, 382, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    if (context.DoNotColor)
                    {
                        AddLabel(50, 385, LabelHue, "*");
                    }

                    AddHtmlLocalized(50 + (context.DoNotColor ? 13 : 0), 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 382, LabelHue, (context.DoNotColor ? "*" : "") + String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                Type resourceType = craftSystem.CraftSubRes2.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                    //daat99 OWLTR start - craft from storage
                    ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, resourceType);
                    if (storageCount > 0)
                    {
                        if (storageCount < int.MaxValue && storageCount + (ulong)resourceCount < int.MaxValue)
                        {
                            resourceCount += (int)storageCount;
                        }
                        else
                        {
                            resourceCount = int.MaxValue;
                        }
                    }
                    //daat99 OWLTR end - craft from storage
                }

                this.AddButton(15, 402, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 405, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 405, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            this.CreateGroupList();

            if (page == CraftPage.PickResource)
            {
                this.CreateResList(false, from);
            }
            else if (page == CraftPage.PickResource2)
            {
                this.CreateResList(true, from);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                this.CreateItemList(context.LastGroupIndex);
            }
        }
Ejemplo n.º 6
0
        private CraftGump(Mobile from, CraftSystem craftSystem, ITool tool, object notice, CraftPage page)
            : base(40, 40)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_Tool        = tool;
            m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            AddPage(0);

            AddBackground(0, 0, 530, 497, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 145, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 477);

            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);  // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER>
            AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER>

            AddButton(15, 442, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 445, 150, 18, 1011441, LabelColor, false, false); // EXIT

            AddButton(115, 442, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0);
            AddHtmlLocalized(150, 445, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE

            // Repair option
            if (m_CraftSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM
            }
            // ****************************************

            // Mark option
            if (m_CraftSystem.MarkOption)
            {
                AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM
            }
            // ****************************************

            // Enhance option
            if (m_CraftSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM
            }
            // ****************************************

            // Alter option
            if (m_CraftSystem.CanAlter)
            {
                AddButton(270, 402, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0);
                AddHtmlLocalized(304, 405, 250, 18, 1094726, LabelColor, false, false); // ALTER ITEM (Gargoyle)
            }
            // ****************************************

            // Quest item
            AddButton(270, 422, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 425, 150, 18, context != null && context.QuestOption == CraftQuestOption.QuestItem ? 1112534 : 1112533, LabelColor, false, false); // QUEST ITEM
            // ****************************************

            AddButton(270, 442, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 445, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST

            int total = 1;
            int made  = 0;

            if (Locked && AutoCraftTimer.AutoCraftTable.ContainsKey(m_From))
            {
                AutoCraftTimer timer = AutoCraftTimer.AutoCraftTable[m_From];

                if (timer != null)
                {
                    total = timer.Amount;
                    made  = timer.Attempts;
                }
                else
                {
                    if (context != null)
                    {
                        total = context.MakeTotal;
                    }
                }
            }

            string args = string.Format("{0}\t{1}", made.ToString(), total.ToString());

            AddHtmlLocalized(270, 468, 150, 18, 1079443, args, LabelColor, false, false); //~1_DONE~/~2_TOTAL~ COMPLETED

            // Resmelt option
            if (m_CraftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM
            }
            // ****************************************

            if (notice is int note && note > 0)
            {
                AddHtmlLocalized(170, 295, 350, 40, note, LabelColor, false, false);
            }
Ejemplo n.º 7
0
			protected override void OnTick()
			{
				m_iCount++;

				m_From.DisruptiveAction();

				if (m_iCount < m_iCountMax)
				{
					m_CraftSystem.PlayCraftEffect(m_From);
				}
				else
				{
					m_From.EndAction(typeof(CraftSystem));

					int badCraft = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.m_Type);

					if (badCraft > 0)
					{
						if (m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0)
						{
							m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, badCraft));
						}
						else
						{
							m_From.SendLocalizedMessage(badCraft);
						}

                        AutoCraftTimer.EndTimer(m_From);

						return;
					}

					int quality = 1;
					bool allRequiredSkills = true;

					m_CraftItem.CheckSkills(m_From, m_TypeRes, m_CraftSystem, ref quality, ref allRequiredSkills, false);

					CraftContext context = m_CraftSystem.GetContext(m_From);

					if (context == null)
					{
						return;
					}

					if (typeof(CustomCraft).IsAssignableFrom(m_CraftItem.ItemType))
					{
						CustomCraft cc = null;

						try
						{
							cc =
								Activator.CreateInstance(
									m_CraftItem.ItemType, new object[] {m_From, m_CraftItem, m_CraftSystem, m_TypeRes, m_Tool, quality}) as
								CustomCraft;
						}
						catch
						{ }

						if (cc != null)
						{
							cc.EndCraftAction();
						}

						return;
					}

					bool makersMark = false;

					if (quality == 2 && m_From.Skills[m_CraftSystem.MainSkill].Base >= 100.0)
					{
						makersMark = m_CraftItem.IsMarkable(m_CraftItem.ItemType);
					}

                    if (makersMark && context.MarkOption == CraftMarkOption.PromptForMark && !m_AutoCraft)
					{
						m_From.SendGump(new QueryMakersMarkGump(quality, m_From, m_CraftItem, m_CraftSystem, m_TypeRes, m_Tool));
					}
					else
					{
						if (context.MarkOption == CraftMarkOption.DoNotMark)
						{
							makersMark = false;
						}

						m_CraftItem.CompleteCraft(quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool, null);
					}
				}
			}
Ejemplo n.º 8
0
		public void CompleteCraft(
			int quality,
			bool makersMark,
			Mobile from,
			CraftSystem craftSystem,
			Type typeRes,
			BaseTool tool,
			CustomCraft customCraft)
		{
			int badCraft = craftSystem.CanCraft(from, tool, m_Type);

			if (badCraft > 0)
			{
				if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, badCraft));
				}
				else
				{
					from.SendLocalizedMessage(badCraft);
				}

                AutoCraftTimer.EndTimer(from);

				return;
			}

			int checkResHue = 0, checkMaxAmount = 0;
			object checkMessage = null;

			// Not enough resource to craft it
			if (!ConsumeRes(from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage))
			{
				if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage));
				}
				else if (checkMessage is int && (int)checkMessage > 0)
				{
					from.SendLocalizedMessage((int)checkMessage);
				}
				else if (checkMessage is string)
				{
					from.SendMessage((string)checkMessage);
				}

                AutoCraftTimer.EndTimer(from);

				return;
			}
			else if (!ConsumeAttributes(from, ref checkMessage, false))
			{
				if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage));
				}
				else if (checkMessage is int && (int)checkMessage > 0)
				{
					from.SendLocalizedMessage((int)checkMessage);
				}
				else if (checkMessage is string)
				{
					from.SendMessage((string)checkMessage);
				}

                AutoCraftTimer.EndTimer(from);

				return;
			}

			bool toolBroken = false;

			int ignored = 1;
			int endquality = 1;

			bool allRequiredSkills = true;

			if (CheckSkills(from, typeRes, craftSystem, ref ignored, ref allRequiredSkills))
			{
				// Resource
				int resHue = 0;
				int maxAmount = 0;

				object message = null;

				// Not enough resource to craft it
				if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message))
				{
					if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
					{
						from.SendGump(new CraftGump(from, craftSystem, tool, message));
					}
					else if (message is int && (int)message > 0)
					{
						from.SendLocalizedMessage((int)message);
					}
					else if (message is string)
					{
						from.SendMessage((string)message);
					}

                    AutoCraftTimer.EndTimer(from);

					return;
				}
				else if (!ConsumeAttributes(from, ref message, true))
				{
					if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
					{
						from.SendGump(new CraftGump(from, craftSystem, tool, message));
					}
					else if (message is int && (int)message > 0)
					{
						from.SendLocalizedMessage((int)message);
					}
					else if (message is string)
					{
						from.SendMessage((string)message);
					}

                    AutoCraftTimer.EndTimer(from);

					return;
				}

				tool.UsesRemaining--;

				if (craftSystem is DefBlacksmithy)
				{
					AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer;
					if (hammer != null && hammer != tool)
					{
						#region Mondain's Legacy
						if (hammer is HammerOfHephaestus)
						{
							if (hammer.UsesRemaining > 0)
							{
								hammer.UsesRemaining--;
							}

							if (hammer.UsesRemaining < 1)
							{
								from.PlaceInBackpack(hammer);
							}
						}
						else
						{
							hammer.UsesRemaining--;

							if (hammer.UsesRemaining < 1)
							{
								hammer.Delete();
							}
						}
						#endregion
					}
				}

				#region Mondain's Legacy
				if (tool is HammerOfHephaestus)
				{
					if (tool.UsesRemaining < 1)
					{
						tool.UsesRemaining = 0;
					}
				}
				else
				{
					if (tool.UsesRemaining < 1)
					{
						toolBroken = true;
					}

					if (toolBroken)
					{
						tool.Delete();
					}
				}
				#endregion

				int num = 0;

				Item item;
				if (customCraft != null)
				{
					item = customCraft.CompleteCraft(out num);
				}
				else if (typeof(MapItem).IsAssignableFrom(ItemType) && from.Map != Map.Trammel && from.Map != Map.Felucca)
				{
					item = new IndecipherableMap();
					from.SendLocalizedMessage(1070800); // The map you create becomes mysteriously indecipherable.
				}
				else
				{
					item = Activator.CreateInstance(ItemType) as Item;
				}

				if (item != null)
				{
					#region Mondain's Legacy
					if (item is Board)
					{
						Type resourceType = typeRes;

						if (resourceType == null)
						{
							resourceType = Resources.GetAt(0).ItemType;
						}

						CraftResource thisResource = CraftResources.GetFromType(resourceType);

						switch (thisResource)
						{
							case CraftResource.OakWood:
								item = new OakBoard();
								break;
							case CraftResource.AshWood:
								item = new AshBoard();
								break;
							case CraftResource.YewWood:
								item = new YewBoard();
								break;
							case CraftResource.Heartwood:
								item = new HeartwoodBoard();
								break;
							case CraftResource.Bloodwood:
								item = new BloodwoodBoard();
								break;
							case CraftResource.Frostwood:
								item = new FrostwoodBoard();
								break;
							default:
								item = new Board();
								break;
						}
					}
					#endregion

					if (item is ICraftable)
					{
						endquality = ((ICraftable)item).OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, this, resHue);
					}
					else if (item is Food)
					{
						((Food)item).PlayerConstructed = true;
					}
					else if (item.Hue == 0)
					{
						item.Hue = resHue;
					}

					if (maxAmount > 0)
					{
						if (!item.Stackable && item is IUsesRemaining)
						{
							((IUsesRemaining)item).UsesRemaining *= maxAmount;
						}
						else
						{
							item.Amount = maxAmount;
						}
					}

					#region Plant Pigments
					if (item is PlantPigment && (craftSystem is DefAlchemy || craftSystem is DefCooking))
					{
						((PlantPigment)item).PigmentHue = PlantPigmentHueInfo.HueFromPlantHue(m_PlantHue);
					}

					if (item is NaturalDye && (craftSystem is DefAlchemy || craftSystem is DefCooking))
					{
						((NaturalDye)item).PigmentHue = PlantPigmentHueInfo.GetInfo(m_PlantPigmentHue).PlantPigmentHue;
					}

					if (item is SoftenedReeds && (craftSystem is DefAlchemy || craftSystem is DefCooking))
					{
						((SoftenedReeds)item).PlantHue = PlantHueInfo.GetInfo(m_PlantHue).PlantHue;
					}

					if (item is BaseContainer && (craftSystem is DefBasketweaving))
					{
						(item).Hue = PlantHueInfo.GetInfo(m_PlantHue).Hue;
					}

                    CraftContext context = craftSystem.GetContext(from);

                    if (context.QuestOption == CraftQuestOption.QuestItem)
                    {
                        PlayerMobile px = from as PlayerMobile;

                        if (!QuestHelper.CheckItem(px, item))
                            from.SendLocalizedMessage(1072355, null, 0x23); // That item does not match any of your quest criteria	
                    }
					#endregion

					if (tool.Parent is Container) {
					Container cntnr = (Container) tool.Parent;
                                        cntnr.TryDropItem(from, item, false);
					}
					else {
					from.AddToBackpack(item);
					}

					EventSink.InvokeCraftSuccess(new CraftSuccessEventArgs(from, item, tool));

					if (from.IsStaff())
					{
						CommandLogging.WriteLine(
							from, "Crafting {0} with craft system {1}", CommandLogging.Format(item), craftSystem.GetType().Name);
					}

                    AutoCraftTimer.OnSuccessfulCraft(from);
					//from.PlaySound( 0x57 );
				}

				if (num == 0)
				{
					num = craftSystem.PlayEndingEffect(from, false, true, toolBroken, endquality, makersMark, this);
				}

				bool queryFactionImbue = false;
				int availableSilver = 0;
				FactionItemDefinition def = null;
				Faction faction = null;

				if (item is IFactionItem)
				{
					def = FactionItemDefinition.Identify(item);

					if (def != null)
					{
						faction = Faction.Find(from);

						if (faction != null)
						{
							Town town = Town.FromRegion(from.Region);

							if (town != null && town.Owner == faction)
							{
								Container pack = from.Backpack;

								if (pack != null)
								{
									availableSilver = pack.GetAmount(typeof(Silver));

									if (availableSilver >= def.SilverCost)
									{
										queryFactionImbue = Faction.IsNearType(from, def.VendorType, 12);
									}
								}
							}
						}
					}
				}

				// TODO: Scroll imbuing

				if (queryFactionImbue)
				{
					from.SendGump(new FactionImbueGump(quality, item, from, craftSystem, tool, num, availableSilver, faction, def));
				}
				else if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, num));
				}
				else if (num > 0)
				{
					from.SendLocalizedMessage(num);
				}
			}
			else if (!allRequiredSkills)
			{
				if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, 1044153));
				}
				else
				{
					from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item.
				}

                AutoCraftTimer.EndTimer(from);
			}
			else
			{
				ConsumeType consumeType = (UseAllRes ? ConsumeType.Half : ConsumeType.All);
				int resHue = 0;
				int maxAmount = 0;

				object message = null;

				// Not enough resource to craft it
				if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true))
				{
					if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
					{
						from.SendGump(new CraftGump(from, craftSystem, tool, message));
					}
					else if (message is int && (int)message > 0)
					{
						from.SendLocalizedMessage((int)message);
					}
					else if (message is string)
					{
						from.SendMessage((string)message);
					}

                    AutoCraftTimer.EndTimer(from);

					return;
				}

				tool.UsesRemaining--;

				if (tool.UsesRemaining < 1)
				{
					toolBroken = true;
				}

				if (toolBroken)
				{
					tool.Delete();
				}

				// SkillCheck failed.
				int num = craftSystem.PlayEndingEffect(from, true, true, toolBroken, endquality, false, this);

				if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
				{
					from.SendGump(new CraftGump(from, craftSystem, tool, num));
				}
				else if (num > 0)
				{
					from.SendLocalizedMessage(num);
				}
			}
		}
Ejemplo n.º 9
0
		public void Craft(Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool)
		{
			if (from.BeginAction(typeof(CraftSystem)))
			{
				if (RequiredExpansion == Expansion.None ||
					(from.NetState != null && from.NetState.SupportsExpansion(RequiredExpansion)))
				{
					bool allRequiredSkills = true;
					double chance = GetSuccessChance(from, typeRes, craftSystem, false, ref allRequiredSkills);

					if (allRequiredSkills && chance >= 0.0)
					{
						if (Recipe == null || !(from is PlayerMobile) || ((PlayerMobile)from).HasRecipe(Recipe))
						{
							int badCraft = craftSystem.CanCraft(from, tool, m_Type);

							if (badCraft <= 0)
							{
								int resHue = 0;
								int maxAmount = 0;
								object message = null;

								if (ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message))
								{
									message = null;

									if (ConsumeAttributes(from, ref message, false))
									{
										CraftContext context = craftSystem.GetContext(from);

										if (context != null)
										{
											context.OnMade(this);
										}

										int iMin = craftSystem.MinCraftEffect;
										int iMax = (craftSystem.MaxCraftEffect - iMin) + 1;
										int iRandom = Utility.Random(iMax);
										iRandom += iMin + 1;
										new InternalTimer(from, craftSystem, this, typeRes, tool, iRandom).Start();
                                        return;
									}
									else
									{
										from.EndAction(typeof(CraftSystem));
										from.SendGump(new CraftGump(from, craftSystem, tool, message));
									}
								}
								else
								{
									from.EndAction(typeof(CraftSystem));
									from.SendGump(new CraftGump(from, craftSystem, tool, message));
								}
							}
							else
							{
								from.EndAction(typeof(CraftSystem));
								from.SendGump(new CraftGump(from, craftSystem, tool, badCraft));
							}
						}
						else
						{
							from.EndAction(typeof(CraftSystem));
							from.SendGump(new CraftGump(from, craftSystem, tool, 1072847)); // You must learn that recipe from a scroll.
						}
					}
					else
					{
						from.EndAction(typeof(CraftSystem));
						from.SendGump(new CraftGump(from, craftSystem, tool, 1044153));
						// You don't have the required skills to attempt this item.
					}
				}
				else
				{
					from.EndAction(typeof(CraftSystem));
					from.SendGump(new CraftGump(from, craftSystem, tool, RequiredExpansionMessage(RequiredExpansion)));
						//The {0} expansion is required to attempt this item.
				}
			}
			else
			{
				from.SendLocalizedMessage(500119); // You must wait to perform another action
			}

            AutoCraftTimer.EndTimer(from);
		}