コード例 #1
0
        public AutoCraftTimer(Mobile from, CraftSystem system, CraftItem item, ITool tool, int amount, TimeSpan delay, TimeSpan interval)
            : base(delay, interval)
        {
            m_From        = from;
            m_CraftSystem = system;
            m_CraftItem   = item;
            m_Tool        = tool;
            m_Amount      = amount;
            m_Ticks       = 0;
            m_Attempts    = 0;

            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)
                {
                    m_TypeRes = res.GetAt(resIndex).ItemType;
                }
            }

            m_AutoCraftTable[from] = this;

            this.Start();
        }
コード例 #2
0
ファイル: CraftGump.cs プロジェクト: uotools/xrunuo
        public static void CraftItem(CraftItem item, CraftSystem system, Mobile from, BaseTool tool)
        {
            int          num     = system.CanCraft(from, tool, item.ItemType);
            CraftContext context = system.GetContext(from);

            if (context == null)
            {
                return;
            }

            if (num > 0)
            {
                context.Making = null;

                from.SendGump(new CraftGump(from, system, tool, num));
            }
            else
            {
                context.Making = item;

                Type type = null;

                CraftSubResCol res      = (item.UseSubRes2 ? system.CraftSubRes2 : system.CraftSubRes);
                int            resIndex = (item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                if (resIndex >= 0 && resIndex < res.Count)
                {
                    type = res.GetAt(resIndex).ItemType;
                }

                system.CreateItem(from, item.ItemType, type, tool, item);
            }
        }
コード例 #3
0
        public void CraftItem(CraftItem item)
        {
            int num = m_CraftSystem.CanCraft(m_From, m_Tool, item.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      = (item.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
                    int            resIndex = (item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                    if (resIndex >= 0 && resIndex < res.Count)
                    {
                        type = res.GetAt(resIndex).ItemType;
                    }
                }

                m_CraftSystem.CreateItem(m_From, item.ItemType, type, m_Tool, item);
            }
        }
コード例 #4
0
        public void CraftItem(CraftItem item)
        {
            object num = m_CraftSystem.CanCraft(m_From, m_Tool, item.ItemType);

            if ((num is int && (int)num > 0) || (num is string && !string.IsNullOrWhiteSpace((string)num)))
            {
                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      = (item.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
                    int            resIndex = (item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                    if (resIndex >= 0 && resIndex < res.Count)
                    {
                        type = res.GetAt(resIndex).ItemType;
                    }
                }

                m_CraftSystem.CreateItem(m_From, item.ItemType, type, m_Tool, item);
            }
        }
コード例 #5
0
ファイル: CraftGumpItem.cs プロジェクト: lishuoipad/ServUO
        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;
            }
        }
コード例 #6
0
        public void DrawSkill()
        {
            for (int i = 0; i < m_CraftItem.Skills.Count; i++)
            {
                CraftSkill skill = m_CraftItem.Skills.GetAt(i);
                double     minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;

                if (minSkill < 0)
                {
                    minSkill = 0;
                }

                AddHtmlLocalized(170, 132 + (i * 20), 200, 18, 1044060 + (int)skill.SkillToMake, LabelColor, false, false);
                AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0:F1}", minSkill));
            }

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool   allRequiredSkills = true;
            double chance            = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills);

            double excepChance = m_CraftItem.GetExceptionalChance(m_CraftSystem, chance, m_From);

            if (chance < 0.0)
            {
                chance = 0.0;
            }
            else if (chance > 1.0)
            {
                chance = 1.0;
            }

            if (excepChance < 0.0)
            {
                excepChance = 0.0;
            }
            else if (excepChance > 1.0)
            {
                excepChance = 1.0;
            }

            AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false);               // Success Chance:
            AddLabel(430, 80, LabelHue, String.Format("{0:F1}%", chance * 100));

            if (m_ShowExceptionalChance)
            {
                AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false);                   // Exceptional Chance:
                AddLabel(430, 100, LabelHue, String.Format("{0:F1}%", excepChance * 100));
            }
        }
コード例 #7
0
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res     = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            CraftContext   context = m_CraftSystem.GetContext(m_From);

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % 10;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                    }

                    AddPage((i / 10) + 1);

                    if (i > 0)
                    {
                        AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                    }

                    //CraftContext context = m_CraftSystem.GetContext( m_From );

                    AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                    AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                }

                int resourceCount = GetResourceAmount(subResource.ItemType);

                AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                if (m_From.NetState.Version >= m_ResourceCountClient)
                {
                    if (subResource.NameNumber > 0)
                    {
                        AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false);
                    }
                    else
                    {
                        AddLabel(255, 60 + (index * 20), LabelHue, subResource.NameString);
                    }
                }
                else if (subResource.NameNumber > 0)
                {
                    AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(255, 60 + (index * 20), LabelHue, String.Format("{0} ({1})", subResource.NameString, resourceCount.ToString()));
                }
            }
        }
コード例 #8
0
ファイル: CraftGump.cs プロジェクト: jicomub/Temrael
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % maxItemPerPage;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        AddButton(485, 360, 4005, 4007, 0, GumpButtonType.Page, (i / maxItemPerPage) + 1);
                    }

                    AddPage((i / maxItemPerPage) + 1);

                    if (i > 0)
                    {
                        AddButton(455, 360, 4014, 4015, 0, GumpButtonType.Page, (i / maxItemPerPage));
                    }

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    //AddButton( 220, 260, 4005, 4007, GetButtonID( 6, 4 ), GumpButtonType.Reply, 0 );
                    //AddHtmlLocalized( 255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false );
                }

                int resourceCount = 0;

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

                    for (int j = 0; j < items.Length; ++j)
                    {
                        resourceCount += items[j].Amount;
                    }
                }

                AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                if (subResource.NameNumber > 0)
                {
                    AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    //AddLabel( 255, 60 + ( index * 20 ), LabelHue, String.Format( "{0} ({1})", subResource.NameString, resourceCount ) );
                    AddHtml(255, 60 + (index * 20), 200, 20, "<h3><basefont color=#FFFFFF>" + subResource.NameString + " [" + resourceCount + "]" + "<basefont></h3>", false, false);
                }
            }
        }
コード例 #9
0
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res = opt ? CraftSystem.CraftSubRes2 : CraftSystem.CraftSubRes;

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % 10;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, i / 10 + 1);
                    }

                    AddPage(i / 10 + 1);

                    if (i > 0)
                    {
                        AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                    }

                    CraftContext context = CraftSystem.GetContext(From);

                    //AddButton( 220, 260, 4005, 4007, GetButtonID( 6, 4 ), GumpButtonType.Reply, 0 );
                    //AddHtmlLocalized( 255, 263, 200, 18, context == null || !context.DoNotColor ? 1061591 : 1061590, LabelColor, false, false );
                }

                int resourceCount = 0;

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

                    for (int j = 0; j < items.Length; ++j)
                    {
                        resourceCount += items[j].Amount;
                    }
                }

                AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                if (subResource.NameNumber > 0)
                {
                    AddHtmlLocalized(255, 63 + index * 20, 250, 18, subResource.NameNumber, resourceCount.ToString(),
                                     LabelColor, false, false);
                }
                else
                {
                    AddLabel(255, 60 + index * 20, LabelHue, $"{subResource.NameString} ({resourceCount})");
                }
            }
        }
コード例 #10
0
ファイル: CraftGumpItem.cs プロジェクト: Pumpk1ns/outlands
        public void DrawItem()
        {
            Type type = m_CraftItem.ItemType;

            int itemID      = CraftItem.ItemIDOf(type);
            int originalHue = 0;

            Item itemCopy = null;

            try { itemCopy = Activator.CreateInstance(type) as Item; }
            catch { }

            if (itemCopy != null)
            {
                originalHue = itemCopy.Hue;
                itemCopy.Delete();
            }

            int itemHue = originalHue;

            if (CraftItem.RetainsColor(type))
            {
                CraftContext context = m_CraftSystem.GetContext(m_From);

                if (context != null)
                {
                    CraftSubResCol craftSubRes = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);

                    int resIndex = -1;

                    resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                    if (resIndex == -1)
                    {
                        resIndex = 0;
                    }

                    CraftSubRes resource = craftSubRes.GetAt(resIndex);

                    //Apply Different Material Color
                    if (resIndex > 0)
                    {
                        itemHue = CraftItem.BaseHueOf(resource.ItemType);
                    }
                }
            }

            AddItem(20, 50, itemID, itemHue);

            if (m_CraftItem.IsMarkable(type))
            {
                AddHtmlLocalized(20, 335 + (m_OtherCount++ *20), 310, 18, 1044059, LabelColor, false, false);                    // This item may hold its maker's mark
                m_ShowExceptionalChance = true;
            }
        }
コード例 #11
0
ファイル: CraftGump.cs プロジェクト: keninishna/ServUO-master
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res = (opt ? this.m_CraftSystem.CraftSubRes2 : this.m_CraftSystem.CraftSubRes);

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % 10;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        this.AddButton(485, 290, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                    }

                    this.AddPage((i / 10) + 1);

                    if (i > 0)
                    {
                        this.AddButton(455, 290, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                    }

                    CraftContext context = this.m_CraftSystem.GetContext(this.m_From);

                    this.AddButton(220, 290, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                    this.AddHtmlLocalized(255, 293, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                }

                int resourceCount = 0;

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

                    for (int j = 0; j < items.Length; ++j)
                    {
                        resourceCount += items[j].Amount;
                    }
                }

                this.AddButton(220, 70 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                if (subResource.NameNumber > 0)
                {
                    this.AddHtmlLocalized(255, 73 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    this.AddLabel(255, 70 + (index * 20), LabelHue, String.Format("{0} ({1})", subResource.NameString, resourceCount));
                }
            }
        }
コード例 #12
0
ファイル: CraftSystem.cs プロジェクト: AlcesAlces/UOsmart
        public CraftSystem( int minCraftEffect, int maxCraftEffect, double delay )
        {
            m_MinCraftEffect = minCraftEffect;
            m_MaxCraftEffect = maxCraftEffect;
            m_Delay = delay;

            m_CraftItems = new CraftItemCol();
            m_CraftGroups = new CraftGroupCol();
            m_CraftSubRes = new CraftSubResCol();
            m_CraftSubRes2 = new CraftSubResCol();

            InitCraftList();
        }
コード例 #13
0
ファイル: CraftSystem.cs プロジェクト: MythikGN/Mythik
        public CraftSystem(int minCraftEffect, int maxCraftEffect, double delay)
        {
            m_MinCraftEffect = minCraftEffect;
            m_MaxCraftEffect = maxCraftEffect;
            m_Delay          = delay;

            m_CraftItems   = new CraftItemCol();
            m_CraftGroups  = new CraftGroupCol();
            m_CraftSubRes  = new CraftSubResCol();
            m_CraftSubRes2 = new CraftSubResCol();

            InitCraftList();
        }
コード例 #14
0
ファイル: CraftSystem.cs プロジェクト: FeehTuffani/ServUO
        public CraftSystem(int minCraftEffect, int maxCraftEffect, double delay)
        {
            this.m_MinCraftEffect = minCraftEffect;
            this.m_MaxCraftEffect = maxCraftEffect;
            this.m_Delay = delay;

            this.m_CraftItems = new CraftItemCol();
            this.m_CraftGroups = new CraftGroupCol();
            this.m_CraftSubRes = new CraftSubResCol();
            this.m_CraftSubRes2 = new CraftSubResCol();

            this.InitCraftList();
            AddSystem(this);
        }
コード例 #15
0
ファイル: CraftGumpItem.cs プロジェクト: Pumpk1ns/outlands
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            //Back
            if (info.ButtonID == 0)
            {
                CraftGump craftGump = new CraftGump(m_From, m_CraftSystem, m_Tool, null);
                m_From.SendGump(craftGump);
            }

            //Guide
            else if (info.ButtonID == 1000)
            {
                string url = "http://www.uoancorp.com";
                sender.Mobile.LaunchBrowser(url);

                m_From.SendGump(new CraftGumpItem(m_From, m_CraftSystem, m_CraftItem, m_Tool));
                return;
            }

            //Make
            else
            {
                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);
                }
            }
        }
コード例 #16
0
        public CraftSystem(int minCraftEffect, int maxCraftEffect, double delay)
        {
            MinCraftEffect = minCraftEffect;
            MaxCraftEffect = maxCraftEffect;
            Delay          = delay;

            CraftItems   = new CraftItemCol();
            CraftGroups  = new CraftGroupCol();
            CraftSubRes  = new CraftSubResCol();
            CraftSubRes2 = new CraftSubResCol();

            InitCraftList();
            AddSystem(this);
        }
コード例 #17
0
ファイル: Enhance.cs プロジェクト: Evad-lab/ServUOX
        public static void BeginTarget(Mobile from, CraftSystem craftSystem, ITool tool)
        {
            CraftContext context = craftSystem.GetContext(from);
            PlayerMobile user    = from as PlayerMobile;

            if (context == null)
            {
                return;
            }

            int            lastRes = context.LastResourceIndex;
            CraftSubResCol subRes  = craftSystem.CraftSubRes;

            if (lastRes >= 0 && lastRes < subRes.Count)
            {
                CraftSubRes res = subRes.GetAt(lastRes);

                if (from.Skills[craftSystem.MainSkill].Value < res.RequiredSkill)
                {
                    from.SendGump(new CraftGump(from, craftSystem, tool, res.Message));
                }
                else
                {
                    CraftResource resource = CraftResources.GetFromType(res.ItemType);

                    if (resource != CraftResource.None)
                    {
                        from.Target = new InternalTarget(craftSystem, tool, res.ItemType, resource);

                        if (user.NextEnhanceSuccess)
                        {
                            from.SendLocalizedMessage(1149869, "100"); // Target an item to enhance with the properties of your selected material (Success Rate: ~1_VAL~%).
                        }
                        else
                        {
                            from.SendLocalizedMessage(1061004); // Target an item to enhance with the properties of your selected material.
                        }
                    }
                    else
                    {
                        from.SendGump(new CraftGump(from, craftSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties.
                    }
                }
            }
            else
            {
                from.SendGump(new CraftGump(from, craftSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties.
            }
        }
コード例 #18
0
        public void DrawChances()
        {
            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool   allRequiredSkills = true;
            double chance            = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills);
            double excepChance       = m_CraftItem.GetExceptionalChance(m_CraftSystem, chance, m_From);

            if (chance > 0.0)
            {
                chance += m_CraftItem.GetTalismanBonus(m_From, m_CraftSystem);
            }

            if (chance < 0.0)
            {
                chance = 0.0;
            }
            else if (chance > 1.0)
            {
                chance = 1.0;
            }

            if (excepChance < 0.0)
            {
                excepChance = 0.0;
            }
            else if (excepChance > 1.0)
            {
                excepChance = 1.0;
            }

            AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false);               // Success Chance:
            AddLabel(430, 80, LabelHue, String.Format("{0:F1}%", chance * 100).Replace(",", "."));

            if (m_ShowExceptionalChance)
            {
                AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false);                   // Exceptional Chance:
                AddLabel(430, 100, LabelHue, String.Format("{0:F1}%", excepChance * 100).Replace(",", "."));
            }
        }
コード例 #19
0
ファイル: CraftSystem.cs プロジェクト: silky/ModernUO
        public CraftSystem(int minCraftEffect, int maxCraftEffect, double delay)
        {
            MinCraftEffect = minCraftEffect;
            MaxCraftEffect = maxCraftEffect;
            Delay          = delay;

            CraftItems   = new List <CraftItem>();
            CraftGroups  = new List <CraftGroup>();
            CraftSubRes  = new CraftSubResCol();
            CraftSubRes2 = new CraftSubResCol();

            m_Recipes     = new List <int>();
            m_RareRecipes = new List <int>();

            InitCraftList();
        }
コード例 #20
0
ファイル: CraftGump.cs プロジェクト: Pumpk1ns/outlands
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % 10;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                    }

                    AddPage((i / 10) + 1);

                    if (i > 0)
                    {
                        AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                    }

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                    AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                }

                int resourceCount = 0;

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

                    for (int j = 0; j < items.Length; ++j)
                    {
                        resourceCount += items[j].Amount;
                    }
                }

                AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);
                AddLabel(255, 60 + (index * 20), LabelHue, subResource.NameString + " (" + resourceCount + " Available)");
            }
        }
コード例 #21
0
        public static void BeginTarget(Mobile from, CraftSystem craftSystem, BaseTool tool)
        {
            if (tool is RuneChisel)
            {
                Runescribing.Enhance(from, tool);
                return;
            }

            CraftContext context = craftSystem.GetContext(from);

            if (context == null)
            {
                return;
            }

            int            lastRes = context.LastResourceIndex;
            CraftSubResCol subRes  = craftSystem.CraftSubRes;

            if (lastRes >= 0 && lastRes < subRes.Count)
            {
                CraftSubRes res = subRes.GetAt(lastRes);

                if (from.Skills[craftSystem.MainSkill].Value < res.RequiredSkill)
                {
                    from.SendGump(new CraftGump(from, craftSystem, tool, res.Message));
                }
                else
                {
                    CraftResource resource = CraftResources.GetFromType(res.ItemType);

                    if (resource != CraftResource.None)
                    {
                        from.Target = new InternalTarget(craftSystem, tool, res.ItemType, resource);
                        from.SendLocalizedMessage(1061004);                           // Target an item to enhance with the properties of your selected material.
                    }
                    else
                    {
                        from.SendGump(new CraftGump(from, craftSystem, tool, 1061010));                             // You must select a special material in order to enhance an item with its properties.
                    }
                }
            }
            else
            {
                from.SendGump(new CraftGump(from, craftSystem, tool, 1061010));                     // You must select a special material in order to enhance an item with its properties.
            }
        }
コード例 #22
0
        public void CreateResList(bool opt)
        {
            CraftSubResCol res = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % 10;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                    }

                    AddPage((i / 10) + 1);

                    if (i > 0)
                    {
                        AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                    }

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                    AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                }

                AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                if (subResource.NameNumber > 0)
                {
                    AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, LabelColor, false, false);
                }
                else
                {
                    //rw3 color hack
                    //AddLabel( 255, 60 + (index * 20), LabelHue, subResource.NameString );
                    AddHtml(255, 63 + (index * 20), 250, 18, "<basefont color=\"" + LabelColor + "\">" + subResource.NameString + "</basefont>", false, false);
                }
            }
        }
コード例 #23
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            // Back Button
            if (info.ButtonID == 0)
            {
                CraftGump craftGump = new CraftGump(m_From, m_CraftSystem, m_Tool, null);
                m_From.SendGump(craftGump);
            }
            else             // Make Button
            {
                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);
                }
            }
        }
コード例 #24
0
ファイル: CraftGump.cs プロジェクト: uotools/xrunuo
        public void CreateResList(bool opt)
        {
            CraftSubResCol res = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);

            AddPage((int)(opt ? CraftPage.PickResource2 : CraftPage.PickResource));

            int residx = opt ? 4000 : 5000;

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % 10;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                        AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                    }

                    CraftContext context = m_CraftSystem.GetContext(m_From);
                }

                AddButton(220, 60 + (index * 20), 4005, 4007, residx + i, GumpButtonType.Reply, 0);

                if (subResource.NameNumber > 0)
                {
                    AddHtmlLocalized(255, 63 + (index * 20), 150, 18, subResource.NameNumber, GetAmount(subResource.ItemType).ToString(), FontColor, false, false);
                }
                else
                {
                    AddLabel(255, 60 + (index * 20), LabelHue, subResource.NameString);
                }
            }
        }
コード例 #25
0
ファイル: CraftGumpItem.cs プロジェクト: zerodowned/vivre-uo
        public void DrawSkill()
        {
            for (int i = 0; i < m_CraftItem.Skills.Count; i++)
            {
                CraftSkill skill = m_CraftItem.Skills.GetAt(i);
                double     minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;

                if (minSkill < 0)
                {
                    minSkill = 0;
                }

                string textminSkills = "Débutant";

                if (minSkill >= 30 && minSkill < 40)
                {
                    textminSkills = "Néophite";
                }
                else if (minSkill >= 40 && minSkill < 50)
                {
                    textminSkills = "Novice";
                }
                else if (minSkill >= 50 && minSkill < 60)
                {
                    textminSkills = "Apprenti";
                }
                else if (minSkill >= 60 && minSkill < 70)
                {
                    textminSkills = "Compagnon";
                }
                else if (minSkill >= 70 && minSkill < 80)
                {
                    textminSkills = "Expert";
                }
                else if (minSkill >= 80 && minSkill < 90)
                {
                    textminSkills = "Adepte";
                }
                else if (minSkill >= 90 && minSkill < 100)
                {
                    textminSkills = "Maître";
                }
                else if (minSkill >= 100 && minSkill < 110)
                {
                    textminSkills = "Grand Maître";
                }

                AddHtmlLocalized(170, 132 + (i * 20), 200, 18, AosSkillBonuses.GetLabel(skill.SkillToMake), LabelColor, false, false);

                if (m_From.AccessLevel >= AccessLevel.GameMaster)
                {
                    AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0:F1}", minSkill));
                }
                else
                {
                    AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0}", textminSkills));
                }
            }

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool   allRequiredSkills = true;
            double chance            = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills);
            double excepChance       = m_CraftItem.GetExceptionalChance(m_CraftSystem, chance, m_From);

            m_Chance = chance;  // Scriptiz : on stocke la chance

            if (chance < 0.0)
            {
                chance = 0.0;
            }
            else if (chance > 1.0)
            {
                chance = 1.0;
            }

            string textchance = "Nulle";

            if (chance > 0 && chance <= 0.2)
            {
                textchance = "Faible";
            }
            else if (chance > 0.2 && chance <= 0.4)
            {
                textchance = "Possible";
            }
            else if (chance > 0.4 && chance <= 0.6)
            {
                textchance = "Moyenne";
            }
            else if (chance > 0.6 && chance <= 0.8)
            {
                textchance = "Favorable";
            }
            else if (chance > 0.8 && chance < 1)
            {
                textchance = "Grande";
            }
            else if (chance == 1)
            {
                textchance = "Aisée";
            }

            AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false);

            if (m_From.AccessLevel >= AccessLevel.GameMaster)
            {
                AddLabel(430, 80, LabelHue, String.Format("{0:F1}%", chance * 100));
            }
            else
            {
                AddLabel(430, 80, LabelHue, String.Format("{0}", textchance));
            }

            if (m_ShowExceptionalChance)
            {
                if (excepChance < 0.0)
                {
                    excepChance = 0.0;
                }
                else if (excepChance > 1.0)
                {
                    excepChance = 1.0;
                }
                if (m_From.AccessLevel >= AccessLevel.GameMaster)
                {
                    AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false);   // Exceptional Chance:
                    AddLabel(430, 100, LabelHue, String.Format("{0:F1}%", excepChance * 100));
                }
            }
        }
コード例 #26
0
        public void DrawResource()
        {
            bool retainedColor = false;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool cropScroll = (m_CraftItem.Resources.Count > 1) &&
                              m_CraftItem.Resources.GetAt(m_CraftItem.Resources.Count - 1).ItemType == typeofBlankScroll &&
                              typeofSpellScroll.IsAssignableFrom(m_CraftItem.ItemType);

            for (int i = 0; i < m_CraftItem.Resources.Count - (cropScroll ? 1 : 0) && i < 4; i++)
            {
                Type   type;
                string nameString;
                int    nameNumber;

                CraftRes craftResource = m_CraftItem.Resources.GetAt(i);

                type       = craftResource.ItemType;
                nameString = craftResource.NameString;
                nameNumber = craftResource.NameNumber;

                // Resource Mutation
                if (type == res.ResType && resIndex > -1)
                {
                    CraftSubRes subResource = res.GetAt(resIndex);

                    type = subResource.ItemType;

                    nameString = subResource.NameString;
                    nameNumber = subResource.GenericNameNumber;

                    if (nameNumber <= 0)
                    {
                        nameNumber = subResource.NameNumber;
                    }
                }
                // ******************

                if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, type))
                {
                    retainedColor = true;
                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1044152, LabelColor, false, false);                        // * The item retains the color of this material
                    AddLabel(500, 219 + (i * 20), LabelHue, "*");
                }

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(170, 219 + (i * 20), LabelHue, nameString);
                }

                AddLabel(430, 219 + (i * 20), LabelHue, craftResource.Amount.ToString());
            }

            if (m_CraftItem.NameNumber == 1041267)               // runebook
            {
                AddHtmlLocalized(170, 219 + (m_CraftItem.Resources.Count * 20), 310, 18, 1044447, LabelColor, false, false);
                AddLabel(430, 219 + (m_CraftItem.Resources.Count * 20), LabelHue, "1");
            }

            if (cropScroll)
            {
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044379, LabelColor, false, false);                    // Inscribing scrolls also requires a blank scroll and mana.
            }
        }
コード例 #27
0
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % 10;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                    }

                    AddPage((i / 10) + 1);

                    if (i > 0)
                    {
                        AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                    }

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    //AddButton( 220, 260, 4005, 4007, GetButtonID( 6, 4 ), GumpButtonType.Reply, 0 );
                    //AddHtmlLocalized( 255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false );
                }

                int resourceCount = 0;

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

                    for (int j = 0; j < items.Length; ++j)
                    {
                        resourceCount += items[j].Amount;
                    }

                    //Taran: Bad fix to check for boards in backpack when using carpenting
                    //Needs to be fixed in a better way
                    if (m_CraftSystem is DefCarpentry)
                    {
                        Item[] item;

                        if (subResource.ItemType == typeof(Log))
                        {
                            item = from.Backpack.FindItemsByType(typeof(Board), true);
                        }
                        else if (subResource.ItemType == typeof(OakLog))
                        {
                            item = from.Backpack.FindItemsByType(typeof(OakBoard), true);
                        }
                        else if (subResource.ItemType == typeof(AshLog))
                        {
                            item = from.Backpack.FindItemsByType(typeof(AshBoard), true);
                        }
                        else if (subResource.ItemType == typeof(YewLog))
                        {
                            item = from.Backpack.FindItemsByType(typeof(YewBoard), true);
                        }
                        else if (subResource.ItemType == typeof(HeartwoodLog))
                        {
                            item = from.Backpack.FindItemsByType(typeof(HeartwoodBoard), true);
                        }
                        else if (subResource.ItemType == typeof(BloodwoodLog))
                        {
                            item = from.Backpack.FindItemsByType(typeof(BloodwoodBoard), true);
                        }
                        else if (subResource.ItemType == typeof(FrostwoodLog))
                        {
                            item = from.Backpack.FindItemsByType(typeof(FrostwoodBoard), true);
                        }
                        else if (subResource.ItemType == typeof(MahoganyLog))
                        {
                            item = from.Backpack.FindItemsByType(typeof(MahoganyBoard), true);
                        }
                        else if (subResource.ItemType == typeof(CedarLog))
                        {
                            item = from.Backpack.FindItemsByType(typeof(CedarBoard), true);
                        }
                        else if (subResource.ItemType == typeof(WillowLog))
                        {
                            item = from.Backpack.FindItemsByType(typeof(WillowBoard), true);
                        }
                        else if (subResource.ItemType == typeof(MystWoodLog))
                        {
                            item = from.Backpack.FindItemsByType(typeof(MystWoodBoard), true);
                        }
                        else
                        {
                            item = from.Backpack.FindItemsByType(typeof(Board), true);
                        }

                        for (int j = 0; j < item.Length; ++j)
                        {
                            resourceCount += item[j].Amount;
                        }
                    }
                }

                AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                if (subResource.NameNumber > 0)
                {
                    AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(255, 60 + (index * 20), LabelHue, String.Format("{0} ({1})", subResource.NameString, resourceCount));
                }
            }
        }
コード例 #28
0
        public CraftGumpItem(Mobile from, CraftSystem craftSystem, CraftItem craftItem, BaseTool tool)
            : base(50, 50)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_CraftItem   = craftItem;
            m_Tool        = tool;

            from.CloseGump <CraftGump>();
            from.CloseGump <CraftGumpItem>();

            AddPage(0);
            AddBackground(0, 0, 530, 417, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 37, 150, 148, 2624);
            AddImageTiled(165, 37, 355, 90, 2624);
            AddImageTiled(10, 190, 155, 22, 2624);
            AddImageTiled(10, 237, 155, 53, 2624);
            AddImageTiled(165, 132, 355, 80, 2624);
            AddImageTiled(10, 275, 155, 22, 2624);
            AddImageTiled(10, 322, 155, 53, 2624);
            AddImageTiled(165, 217, 355, 80, 2624);
            AddImageTiled(10, 360, 155, 22, 2624);
            AddImageTiled(165, 302, 355, 80, 2624);
            AddImageTiled(10, 387, 510, 22, 2624);
            AddAlphaRegion(10, 10, 510, 397);

            AddHtmlLocalized(170, 40, 150, 20, 1044053, LabelColor, false, false);               // ITEM
            AddHtmlLocalized(10, 215, 150, 22, 1044055, LabelColor, false, false);               // <CENTER>MATERIALS</CENTER>
            AddHtmlLocalized(10, 300, 150, 22, 1044056, LabelColor, false, false);               // <CENTER>OTHER</CENTER>

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

            AddButton(15, 387, 4014, 4016, 9999, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 390, 150, 18, 1044150, LabelColor, false, false);               // BACK

            // Draw Item
            Type type = m_CraftItem.ItemType;

            if (m_CraftItem.IsMarkable(type))
            {
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1044059, LabelColor, false, false);                      // This item may hold its maker's mark
                m_ShowExceptionalChance = true;
            }

            if (craftItem.NameNumber > 0)
            {
                AddHtmlLocalized(330, 40, 180, 18, craftItem.NameNumber, LabelColor, false, false);
            }
            else
            {
                AddLabel(330, 40, LabelHue, craftItem.NameString);
            }

            AddItem(20, 50, CraftItem.ItemIDOf(type));
            // ***********************************

            // Draw Skills
            for (int i = 0; i < m_CraftItem.Skills.Count; i++)
            {
                CraftSkill skill    = m_CraftItem.Skills.GetAt(i);
                double     minSkill = skill.MinSkill;

                if (minSkill < 0)
                {
                    minSkill = 0;
                }

                AddHtmlLocalized(170, 132 + (i * 20), 200, 18, 1044060 + (int)skill.SkillToMake, LabelColor, false, false);
                AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0:F1}", minSkill).Replace(",", "."));
            }
            // ***********************************

            // Draw Ressource
            bool retainedColor = false;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool cropScroll = (m_CraftItem.Ressources.Count > 1) && m_CraftItem.Ressources.GetAt(m_CraftItem.Ressources.Count - 1).ItemType == typeofBlankScroll && typeofSpellScroll.IsAssignableFrom(m_CraftItem.ItemType);

            for (int i = 0; i < m_CraftItem.Ressources.Count - (cropScroll ? 1 : 0) && i < 4; i++)
            {
                Type   _type;
                string nameString;
                int    nameNumber;

                CraftRes craftResource = m_CraftItem.Ressources.GetAt(i);

                _type      = craftResource.ItemType;
                nameString = craftResource.NameString;
                nameNumber = craftResource.NameNumber;
                int amount = craftResource.Amount;

                // Resource Mutation
                if (_type == res.ResType && resIndex > -1)
                {
                    CraftSubRes subResource = res.GetAt(resIndex);

                    _type = subResource.ItemType;

                    nameString = subResource.NameString;
                    nameNumber = subResource.GenericNameNumber;

                    if (nameNumber <= 0)
                    {
                        nameNumber = subResource.NameNumber;
                    }
                }
                // ******************

                if (m_CraftItem.NameNumber == 1044458)                   // cut-up cloth
                {
                    amount = 0;

                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044460, LabelColor, false, false);                          // Cut bolts of cloth into pieces of ready cloth.
                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1048176, LabelColor, false, false);                          // Makes as many as possible at once
                }

                if (m_CraftItem.NameNumber == 1044459)                   //combine cloth
                {
                    amount = 0;

                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044461, LabelColor, false, false);                          // Combine available cloth into piles by color.
                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1048176, LabelColor, false, false);                          // Makes as many as possible at once
                }

                if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, _type))
                {
                    retainedColor = true;
                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1044152, LabelColor, false, false);                          // * The item retains the color of this material
                    AddLabel(500, 219 + (i * 20), LabelHue, "*");
                }

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(170, 219 + (i * 20), LabelHue, nameString);
                }

                AddHtml(430, 219 + (i * 20), 40, 20, String.Format("<basefont color=#FFFFFF><div align=right>{0}</basefont></div>", amount.ToString()), false, false);
            }

            if (m_CraftItem.NameNumber == 1041267)               // runebook
            {
                AddHtmlLocalized(170, 219 + (m_CraftItem.Ressources.Count * 20), 310, 18, 1044447, LabelColor, false, false);
                AddHtml(430, 219 + (m_CraftItem.Ressources.Count * 20), 40, 20, String.Format("<basefont color=#FFFFFF><div align=right>{0}</basefont></div>", "1"), false, false);
            }
            // ***********************************

            if (craftItem.UseAllRes)
            {
                // Makes as many as possible at once
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1048176, LabelColor, false, false);
            }

            if (craftItem.RequiresSE)
            {
                // * Requires the "Samurai Empire" expansion
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1063363, LabelColor, false, false);
            }

            if (craftItem.RequiresML)
            {
                // * Requires the "Mondain's Legacy" expansion
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1072651, LabelColor, false, false);
            }

            if (craftItem.RequiresSA)
            {
                // * Requires the "Stygian Abyss" expansion
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1094732, LabelColor, false, false);
            }

            if (craftItem.RequiresHS)
            {
                // * Requires the "High Seas" booster
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1116296, LabelColor, false, false);
            }

            bool needsRecipe = (craftItem.Recipe != null && from is PlayerMobile && !((PlayerMobile)from).HasRecipe(craftItem.Recipe));

            if (needsRecipe)
            {
                // You have not learned this recipe.
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1073620, RedLabelColor, false, false);
            }

            if (cropScroll)
            {
                // Inscribing scrolls also requires a blank scroll and mana.
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044379, LabelColor, false, false);
            }

            if (needsRecipe)
            {
                AddButton(135, 387, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 0);
                AddHtmlLocalized(180, 390, 150, 18, 1112624, 0x3DEF, false, false);                   // MAKE MAX

                AddButton(255, 387, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 0);
                AddHtmlLocalized(300, 390, 150, 18, 1112623, 0x3DEF, false, false);                   // MAKE NUMBER

                AddButton(405, 387, 4005, 4007, 0, GumpButtonType.Page, 0);
                AddHtmlLocalized(450, 390, 150, 18, 1044151, GreyLabelColor, false, false);                   // MAKE NOW
            }
            else
            {
                AddButton(135, 387, 0xFAE, 0xFB0, craftItem.CraftId + 11000, GumpButtonType.Reply, 0);
                AddHtmlLocalized(180, 390, 150, 18, 1112624, 0x7FFF, false, false);                   // MAKE MAX

                AddButton(255, 387, 0xFAE, 0xFB0, craftItem.CraftId + 10000, GumpButtonType.Reply, 0);
                AddHtmlLocalized(300, 390, 150, 18, 1112623, 0x7FFF, false, false);                   // MAKE NUMBER

                AddButton(405, 387, 4005, 4007, craftItem.CraftId, GumpButtonType.Reply, 0);
                AddHtmlLocalized(450, 390, 150, 18, 1044151, LabelColor, false, false);                   // MAKE NOW
            }

            // Draw Chances
            DrawChances();
            // ***********************************
        }
コード例 #29
0
        public async void CraftItem(CraftItem item)
        {
            var num = CraftSystem.CanCraft(From, Tool, item.ItemType);

            if (num > 0)
            {
                From.SendGump(new CraftGump(From, CraftSystem, Tool, num));
            }
            else if (From.NextSkillTime > Core.TickCount)
            {
                From.SendGump(new CraftGump(From, CraftSystem, Tool, 1045157)); // You must wait to perform another action.
            }
            else
            {
                Type type = null;

                CraftContext context = CraftSystem.GetContext(From);

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

                    if (resIndex >= 0 && resIndex < res.Count)
                    {
                        type = res.GetAt(resIndex).ItemType;
                    }
                }

                var success          = false;
                var fromPrevLocation = From.Location;

                for (var i = context.CraftNumber; i >= 0; i--)
                {
                    if (i == 0)
                    {
                        From.SendAsciiMessage(89, "You finished looping.");
                        return;
                    }

                    var badCraft = CraftSystem.CanCraft(From, Tool, item.ItemType);
                    if (badCraft > 0)
                    {
                        From.SendAsciiMessage(89, "Looping aborted.");
                        return;
                    }

                    if (From.Location != fromPrevLocation)
                    {
                        From.SendAsciiMessage(89, "You moved. Looping aborted.");
                        return;
                    }

                    From.CloseGump <CraftGump>();
                    From.CloseGump <CraftGumpItem>();

                    CraftSystem.CreateItem(From, item.ItemType, type, Tool, item, ref success);

                    if (!success)
                    {
                        return;
                    }

                    From.SendAsciiMessage(89, $"Looping [{i} more to go].");

                    var loopDelay = ((int)(CraftSystem.Delay * CraftSystem.MaxCraftEffect) + (int)ZhConfig.Crafting.AutoLoop.Delay) * 1000;

                    From.NextSkillTime = Core.TickCount + loopDelay;

                    await Timer.Pause(loopDelay);
                }
            }
        }
コード例 #30
0
ファイル: CraftGumpItem.cs プロジェクト: Pumpk1ns/outlands
        public void DrawSkill()
        {
            for (int i = 0; i < m_CraftItem.Skills.Count; i++)
            {
                CraftSkill skill = m_CraftItem.Skills.GetAt(i);
                double     minSkill = skill.MinSkill, maxSkill = skill.MaxSkill;

                if (minSkill < 0)
                {
                    minSkill = 0;
                }

                AddHtmlLocalized(170, 155 + (i * 20), 200, 18, AosSkillBonuses.GetLabel(skill.SkillToMake), LabelColor, false, false);
                AddLabel(430, 155 + (i * 20), LabelHue, String.Format("{0:F1}", minSkill));
            }

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool allRequiredSkills = true;

            double successChance     = m_CraftItem.GetSuccessChance(m_From, resIndex > -1 ? res.GetAt(resIndex).ItemType : null, m_CraftSystem, false, ref allRequiredSkills);
            double exceptionalChance = m_CraftItem.GetExceptionalChance(m_CraftSystem, successChance, m_From);

            bool skillGainPossible = false;

            if (successChance < 0.0)
            {
                successChance = 0.0;
            }

            else if (successChance > 1.0)
            {
                successChance = 1.0;
            }

            if (exceptionalChance < 0.0)
            {
                exceptionalChance = 0.0;
            }

            else if (exceptionalChance > 1.0)
            {
                exceptionalChance = 1.0;
            }

            if (successChance > 0 && successChance < 1.0)
            {
                skillGainPossible = true;
            }

            int startY = 80;

            AddHtmlLocalized(170, startY, 250, 18, 1044057, LabelColor, false, false); // Success Chance:
            AddLabel(430, startY, LabelHue, String.Format("{0:F1}%", successChance * 100));

            startY += 20;

            if (m_ShowExceptionalChance)
            {
                if (exceptionalChance < 0.0)
                {
                    exceptionalChance = 0.0;
                }

                else if (exceptionalChance > 1.0)
                {
                    exceptionalChance = 1.0;
                }

                AddHtmlLocalized(170, startY, 250, 18, 1044058, 32767, false, false); // Exceptional Chance:
                AddLabel(430, startY, LabelHue, String.Format("{0:F1}%", exceptionalChance * 100));

                startY += 20;
            }

            if (skillGainPossible)
            {
                AddLabel(169, startY, 2599, "Skill Gain Possible");
            }
        }
コード例 #31
0
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res = (opt ? this.m_CraftSystem.CraftSubRes2 : this.m_CraftSystem.CraftSubRes);
            //daat99 OWLTR start - recipe craft
            bool b_RecipeCraft  = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.RECIPE_CRAFT),
                 b_Blacksmithy  = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.BLACKSMITH_RECIPES),
                 b_BowFletching = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.BOWFLETCH_RECIPES),
                 b_Carpentry    = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.CARPENTRY_RECIPES),
                 b_Masonry      = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.MASONRY_RECIPES),
                 b_Tailoring    = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.TAILORING_RECIPES),
                 b_Tinkering    = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.TINKERING_RECIPES);

            if (b_RecipeCraft)
            {
                NewDaat99Holder dh       = (NewDaat99Holder)daat99.Daat99OWLTR.TempHolders[m_From];
                int             i_Lenght = 0;
                for (int i = 0; i < res.Count; ++i)
                {
                    int index = i_Lenght % 10;

                    CraftSubRes subResource = res.GetAt(i);
                    if (!dh.Resources.Contains(CraftResources.GetFromType(subResource.ItemType)) || (!b_Blacksmithy && m_CraftSystem is DefBlacksmithy) ||
                        (!b_BowFletching && m_CraftSystem is DefBowFletching) || (!b_Carpentry && m_CraftSystem is DefCarpentry) ||
                        (!b_Masonry && m_CraftSystem is DefMasonry) || (!b_Tailoring && m_CraftSystem is DefTailoring) ||
                        (!b_Tinkering && m_CraftSystem is DefTinkering))
                    {
                        if (index == 0)
                        {
                            if (i > 0)
                            {
                                AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                            }

                            AddPage((i / 10) + 1);

                            if (i > 0)
                            {
                                AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                            }

                            CraftContext context = m_CraftSystem.GetContext(m_From);

                            AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                            AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                        }

                        AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                        if (subResource.NameNumber > 0)
                        {
                            AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, LabelColor, false, false);
                        }
                        else
                        {
                            AddLabel(255, 60 + (index * 20), LabelHue, subResource.NameString);
                        }
                        i_Lenght++;
                    }
                }
            }
            else
            {
                //daat99 OWLTR end - recipe craft
                for (int i = 0; i < res.Count; ++i)
                {
                    int index = i % 10;

                    CraftSubRes subResource = res.GetAt(i);

                    if (index == 0)
                    {
                        if (i > 0)
                        {
                            this.AddButton(485, 290, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                        }

                        this.AddPage((i / 10) + 1);

                        if (i > 0)
                        {
                            this.AddButton(455, 290, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                        }

                        CraftContext context = this.m_CraftSystem.GetContext(this.m_From);

                        this.AddButton(220, 290, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                        this.AddHtmlLocalized(255, 293, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                    }

                    int resourceCount = 0;

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

                        for (int j = 0; j < items.Length; ++j)
                        {
                            resourceCount += items[j].Amount;
                        }
                        //daat99 OWLTR start - craft from storage
                        ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, subResource.ItemType);
                        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(220, 70 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                    if (subResource.NameNumber > 0)
                    {
                        this.AddHtmlLocalized(255, 73 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false);
                    }
                    else
                    {
                        this.AddLabel(255, 70 + (index * 20), LabelHue, String.Format("{0} ({1})", subResource.NameString, resourceCount));
                    }
                }
            }
        }
コード例 #32
0
        public bool ConsumeRes(Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message, bool isFailure)
        {
            Container ourPack = from.Backpack;

            if (ourPack == null)
            {
                return(false);
            }

            if (m_NeedHeat && !Find(from, m_HeatSources))
            {
                message = 1044487; // You must be near a fire source to cook.
                return(false);
            }

            if (m_NeedOven && !Find(from, m_Ovens))
            {
                message = 1044493; // You must be near an oven to bake that.
                return(false);
            }

            if (m_NeedMill && !Find(from, m_Mills))
            {
                message = 1044491; // You must be near a flour mill to do that.
                return(false);
            }

            Type[][] types   = new Type[m_arCraftRes.Count][];
            int[]    amounts = new int[m_arCraftRes.Count];

            maxAmount = int.MaxValue;

            CraftSubResCol resCol = (m_UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes);

            for (int i = 0; i < types.Length; ++i)
            {
                CraftRes craftRes = m_arCraftRes.GetAt(i);
                Type     baseType = craftRes.ItemType;

                // Resource Mutation
                if ((baseType == resCol.ResType) && (typeRes != null))
                {
                    baseType = typeRes;

                    CraftSubRes subResource = resCol.SearchFor(baseType);

                    if (subResource != null && from.Skills[craftSystem.MainSkill].Base < subResource.RequiredSkill)
                    {
                        message = subResource.Message;
                        return(false);
                    }
                }
                // ******************

                for (int j = 0; types[i] == null && j < m_TypesTable.Length; ++j)
                {
                    if (m_TypesTable[j][0] == baseType)
                    {
                        types[i] = m_TypesTable[j];
                    }
                }

                if (types[i] == null)
                {
                    types[i] = new Type[] { baseType }
                }
                ;

                amounts[i] = craftRes.Amount;

                // For stackable items that can ben crafted more than one at a time
                if (UseAllRes)
                {
                    int tempAmount = ourPack.GetAmount(types[i]);
                    tempAmount /= amounts[i];
                    if (tempAmount < maxAmount)
                    {
                        maxAmount = tempAmount;

                        if (maxAmount == 0)
                        {
                            CraftRes res = m_arCraftRes.GetAt(i);

                            if (res.MessageNumber > 0)
                            {
                                message = res.MessageNumber;
                            }
                            else if (!String.IsNullOrEmpty(res.MessageString))
                            {
                                message = res.MessageString;
                            }
                            else
                            {
                                message = 502925; // You don't have the resources required to make that item.
                            }
                            return(false);
                        }
                    }
                }
                // ****************************

                if (isFailure && !craftSystem.ConsumeOnFailure(from, types[i][0], this))
                {
                    amounts[i] = 0;
                }
            }

            // We adjust the amount of each resource to consume the max posible
            if (UseAllRes)
            {
                for (int i = 0; i < amounts.Length; ++i)
                {
                    amounts[i] *= maxAmount;
                }
            }
            else
            {
                maxAmount = -1;
            }

            Item consumeExtra = null;

            if (m_NameNumber == 1041267)
            {
                // Runebooks are a special case, they need a blank recall rune

                List <RecallRune> runes = ourPack.FindItemsByType <RecallRune>();

                for (int i = 0; i < runes.Count; ++i)
                {
                    RecallRune rune = runes[i];

                    if (rune != null && !rune.Marked)
                    {
                        consumeExtra = rune;
                        break;
                    }
                }

                if (consumeExtra == null)
                {
                    message = 1044253; // You don't have the components needed to make that.
                    return(false);
                }
            }

            int index = 0;

            // Consume ALL
            if (consumeType == ConsumeType.All)
            {
                m_ResHue = 0; m_ResAmount = 0; m_System = craftSystem;

                if (from is Player)
                {
                    Craftsman cm = Perk.GetByType <Craftsman>(from as Player);

                    if (cm != null && cm.Efficient())
                    {
                        for (int i = 0; i < amounts.Length; i++)
                        {   //Reduce all resources used by one if result is greater than one.
                            if (amounts[i] - 1 > 1)
                            {
                                amounts[i]--;
                            }
                        }
                    }
                }

                if (IsQuantityType(types))
                {
                    index = ConsumeQuantity(ourPack, types, amounts);
                }
                else
                {
                    index = ourPack.ConsumeTotalGrouped
                                (types, amounts, true, new OnItemConsumed(OnResourceConsumed), new CheckItemGroup(CheckHueGrouping));
                }

                resHue = m_ResHue;
            }

            // Consume Half ( for use all resource craft type )
            else if (consumeType == ConsumeType.Half)
            {
                for (int i = 0; i < amounts.Length; i++)
                {
                    amounts[i] /= 2;

                    if (amounts[i] < 1)
                    {
                        amounts[i] = 1;
                    }
                }

                m_ResHue = 0; m_ResAmount = 0; m_System = craftSystem;

                if (IsQuantityType(types))
                {
                    index = ConsumeQuantity(ourPack, types, amounts);
                }
                else
                {
                    index = ourPack.ConsumeTotalGrouped
                                (types, amounts, true, new OnItemConsumed(OnResourceConsumed), new CheckItemGroup(CheckHueGrouping));
                }

                resHue = m_ResHue;
            }
            else // ConstumeType.None ( it's basicaly used to know if the crafter has enough resource before starting the process )
            {
                index = -1;

                if (IsQuantityType(types))
                {
                    for (int i = 0; i < types.Length; i++)
                    {
                        if (GetQuantity(ourPack, types[i]) < amounts[i])
                        {
                            index = i;
                            break;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < types.Length; i++)
                    {
                        if (ourPack.GetBestGroupAmount(types[i], true, new CheckItemGroup(CheckHueGrouping)) < amounts[i])
                        {
                            index = i;
                            break;
                        }
                    }
                }
            }

            if (index == -1)
            {
                if (consumeType != ConsumeType.None)
                {
                    if (consumeExtra != null)
                    {
                        consumeExtra.Delete();
                    }
                }

                return(true);
            }
            else
            {
                CraftRes res = m_arCraftRes.GetAt(index);

                if (res.MessageNumber > 0)
                {
                    message = res.MessageNumber;
                }
                else if (res.MessageString != null && res.MessageString != String.Empty)
                {
                    message = res.MessageString;
                }
                else
                {
                    message = 502925; // You don't have the resources required to make that item.
                }
                return(false);
            }
        }