Ejemplo n.º 1
0
        public void DrawLokaiSkill()
        {
            for (int i = 0; i < m_BuildItem.LokaiSkills.Count; i++)
            {
                BuildLokaiSkill lokaiSkill = m_BuildItem.LokaiSkills.GetAt(i);
                double          minLokaiSkill = lokaiSkill.MinLokaiSkill, maxLokaiSkill = lokaiSkill.MaxLokaiSkill;

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

                AddHtmlLocalized(170, 132 + (i * 20), 200, 18, 1070722, lokaiSkill.LokaiSkillToMake.ToString(), LabelColor, false, false);
                AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0:F1}", minLokaiSkill));
            }

            BuildSubResCol res      = (m_BuildItem.UseSubRes2 ? m_BuildSystem.BuildSubRes2 : m_BuildSystem.BuildSubRes);
            int            resIndex = -1;

            BuildContext context = m_BuildSystem.GetContext(m_From);

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

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

            if (chance < 0.0)
            {
                chance = 0.0;
            }
            else if (chance > 1.0)
            {
                chance = 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)
            {
                if (excepChance < 0.0)
                {
                    excepChance = 0.0;
                }
                else if (excepChance > 1.0)
                {
                    excepChance = 1.0;
                }

                AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false);                   // Exceptional Chance:
                AddLabel(430, 100, LabelHue, String.Format("{0:F1}%", excepChance * 100));
            }
        }
Ejemplo n.º 2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (!CheckDeed(from))
                {
                    return;
                }


                bool usingDeed = (m_Deed != null);
                bool toDelete  = false;

                if (targeted is Item)
                {
                    number = (usingDeed)? 1061136 : 1044277;                     // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                if (!usingDeed)
                {
                    BuildContext context = m_BuildSystem.GetContext(from);
                    from.SendGump(new BuildGump(from, m_BuildSystem, m_Tool, number));
                }
                else if (toDelete)
                {
                    m_Deed.Delete();
                }
            }
Ejemplo n.º 3
0
        public void CreateResList(bool opt)
        {
            BuildSubResCol res = (opt ? m_BuildSystem.BuildSubRes2 : m_BuildSystem.BuildSubRes);

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

                BuildSubRes 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);
                    }

                    BuildContext context = m_BuildSystem.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);
                }
            }
        }
Ejemplo n.º 4
0
        public static void BeginTarget(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool)
        {
            BuildContext context = buildSystem.GetContext(from);

            if (context == null)
            {
                return;
            }

            int            lastRes = context.LastResourceIndex;
            BuildSubResCol subRes  = buildSystem.BuildSubRes;

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

                if (LokaiSkillUtilities.XMLGetSkills(from)[buildSystem.MainLokaiSkill].Value < res.RequiredLokaiSkill)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, res.Message));
                }
                else
                {
                    BuildResource resource = BuildResources.GetFromType(res.ItemType);

                    if (resource != BuildResource.None)
                    {
                        from.Target = new InternalTarget(buildSystem, tool, res.ItemType, resource);
                        from.SendLocalizedMessage(1061004);                           // Target an item to enhance with the properties of your selected material.
                    }
                    else
                    {
                        from.SendGump(new BuildGump(from, buildSystem, tool, 1061010));                             // You must select a special material in order to enhance an item with its properties.
                    }
                }
            }
            else
            {
                from.SendGump(new BuildGump(from, buildSystem, tool, 1061010));                     // You must select a special material in order to enhance an item with its properties.
            }
        }
Ejemplo n.º 5
0
        public void Build(Mobile from, BuildSystem buildSystem, Type typeRes, BaseBuildingTool tool)
        {
            if (from.BeginAction(typeof(BuildSystem)))
            {
                if (RequiredExpansion == Expansion.None || (from.NetState != null && from.NetState.SupportsExpansion(RequiredExpansion)))
                {
                    bool   allRequiredLokaiSkills = true;
                    double chance = GetSuccessChance(from, typeRes, buildSystem, false, ref allRequiredLokaiSkills);

                    if (allRequiredLokaiSkills && chance >= 0.0)
                    {
                        if (this.Recipe == null)
                        {
                            int badBuild = buildSystem.CanBuild(from, tool, m_Type);

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

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

                                    if (ConsumeAttributes(from, ref message, false))
                                    {
                                        BuildContext context = buildSystem.GetContext(from);

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

                                        int iMin    = buildSystem.MinBuildEffect;
                                        int iMax    = (buildSystem.MaxBuildEffect - iMin) + 1;
                                        int iRandom = Utility.Random(iMax);
                                        iRandom += iMin + 1;
                                        new InternalTimer(from, buildSystem, this, typeRes, tool, iRandom).Start();
                                    }
                                    else
                                    {
                                        from.EndAction(typeof(BuildSystem));
                                        from.SendGump(new BuildGump(from, buildSystem, tool, message));
                                    }
                                }
                                else
                                {
                                    from.EndAction(typeof(BuildSystem));
                                    from.SendGump(new BuildGump(from, buildSystem, tool, message));
                                }
                            }
                            else
                            {
                                from.EndAction(typeof(BuildSystem));
                                from.SendGump(new BuildGump(from, buildSystem, tool, badBuild));
                            }
                        }
                        else
                        {
                            from.EndAction(typeof(BuildSystem));
                            from.SendGump(new BuildGump(from, buildSystem, tool, 1072847));                                 // You must learn that recipe from a scroll.
                        }
                    }
                    else
                    {
                        from.EndAction(typeof(BuildSystem));
                        from.SendGump(new BuildGump(from, buildSystem, tool, 1044153));                             // You don't have the required lokaiSkills to attempt this item.
                    }
                }
                else
                {
                    from.EndAction(typeof(BuildSystem));
                    from.SendGump(new BuildGump(from, buildSystem, tool, RequiredExpansionMessage(RequiredExpansion)));                           //The {0} expansion is required to attempt this item.
                }
            }
            else
            {
                from.SendLocalizedMessage(500119);                   // You must wait to perform another action
            }
        }
Ejemplo n.º 6
0
            protected override void OnTick()
            {
                m_iCount++;

                m_From.DisruptiveAction();

                if (m_iCount < m_iCountMax)
                {
                    m_BuildSystem.PlayBuildEffect(m_From);
                }
                else
                {
                    m_From.EndAction(typeof(BuildSystem));

                    int badBuild = m_BuildSystem.CanBuild(m_From, m_Tool, m_BuildItem.m_Type);

                    if (badBuild > 0)
                    {
                        if (m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0)
                        {
                            m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, badBuild));
                        }
                        else
                        {
                            m_From.SendLocalizedMessage(badBuild);
                        }

                        return;
                    }

                    int  quality = 1;
                    bool allRequiredLokaiSkills = true;

                    m_BuildItem.CheckLokaiSkills(m_From, m_TypeRes, m_BuildSystem, ref quality, ref allRequiredLokaiSkills, false);

                    BuildContext context = m_BuildSystem.GetContext(m_From);

                    if (context == null)
                    {
                        return;
                    }

                    if (typeof(CustomBuild).IsAssignableFrom(m_BuildItem.ItemType))
                    {
                        CustomBuild cc = null;

                        try{ cc = Activator.CreateInstance(m_BuildItem.ItemType, new object[] { m_From, m_BuildItem, m_BuildSystem, m_TypeRes, m_Tool, quality }) as CustomBuild; }
                        catch {}

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

                        return;
                    }

                    bool makersMark = false;

                    if (quality == 2 && LokaiSkillUtilities.XMLGetSkills(m_From)[m_BuildSystem.MainLokaiSkill].Base >= 100.0)
                    {
                        makersMark = m_BuildItem.IsMarkable(m_BuildItem.ItemType);
                    }

                    if (makersMark && context.MarkOption == BuildMarkOption.PromptForMark)
                    {
                        m_From.SendGump(new QueryMakersMarkGump(quality, m_From, m_BuildItem, m_BuildSystem, m_TypeRes, m_Tool));
                    }
                    else
                    {
                        if (context.MarkOption == BuildMarkOption.DoNotMark)
                        {
                            makersMark = false;
                        }

                        m_BuildItem.CompleteBuild(quality, makersMark, m_From, m_BuildSystem, m_TypeRes, m_Tool, null);
                    }
                }
            }
Ejemplo n.º 7
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;

            BuildSystem   system  = m_BuildSystem;
            BuildGroupCol groups  = system.BuildGroups;
            BuildContext  context = system.GetContext(m_From);

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

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

                break;
            }

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

                int groupIndex = context.LastGroupIndex;

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

                    if (index >= 0 && index < group.BuildItems.Count)
                    {
                        BuildItem(group.BuildItems.GetAt(index));
                    }
                }

                break;
            }

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

                int groupIndex = context.LastGroupIndex;

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

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

                break;
            }

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

                ArrayList lastTen = context.Items;

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

                break;
            }

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

                ArrayList lastTen = context.Items;

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

                break;
            }

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

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

                    if (LokaiSkillUtilities.XMLGetSkills(m_From)[system.MainLokaiSkill].Base < res.RequiredLokaiSkill)
                    {
                        m_From.SendGump(new BuildGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

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

                    BuildSubRes res = system.BuildSubRes2.GetAt(index);

                    if (LokaiSkillUtilities.XMLGetSkills(m_From)[system.MainLokaiSkill].Base < res.RequiredLokaiSkill)
                    {
                        m_From.SendGump(new BuildGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

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

                break;
            }

            case 6:                     // Misc. buttons
            {
                switch (index)
                {
                case 0:                                 // Resource selection
                {
                    if (system.BuildSubRes.Init)
                    {
                        m_From.SendGump(new BuildGump(m_From, system, m_Tool, null, BuildPage.PickResource));
                    }

                    break;
                }

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

                    break;
                }

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

                    BuildItem item = context.LastMade;

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

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

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

                    break;
                }

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

                    context.DoNotColor = !context.DoNotColor;

                    m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, null, m_Page));

                    break;
                }

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

                    break;
                }

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

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

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

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

                    m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, null, m_Page));

                    break;
                }

                case 7:                                 // Resource selection 2
                {
                    if (system.BuildSubRes2.Init)
                    {
                        m_From.SendGump(new BuildGump(m_From, system, m_Tool, null, BuildPage.PickResource2));
                    }

                    break;
                }

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

                    break;
                }
                }

                break;
            }
            }
        }
Ejemplo n.º 8
0
        private BuildGump(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool, object notice, BuildPage page) : base(40, 40)
        {
            m_From        = from;
            m_BuildSystem = buildSystem;
            m_Tool        = tool;
            m_Page        = page;

            BuildContext context = buildSystem.GetContext(from);

            from.CloseGump(typeof(BuildGump));
            from.CloseGump(typeof(BuildGumpItem));

            AddPage(0);

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

            if (buildSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, buildSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, MakeTitle(buildSystem.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, 402, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor, false, false);               // EXIT

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

            // Mark option
            if (buildSystem.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
            }
            // ****************************************

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

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

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

            if (notice is int && (int)notice > 0)
            {
                AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                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 (buildSystem.BuildSubRes.Init)
            {
                string nameString = buildSystem.BuildSubRes.NameString;
                int    nameNumber = buildSystem.BuildSubRes.NameNumber;

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

                Type resourceType = buildSystem.BuildSubRes.ResType;

                if (resIndex > -1)
                {
                    BuildSubRes subResource = buildSystem.BuildSubRes.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;
                    }
                }

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

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

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

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

                Type resourceType = buildSystem.BuildSubRes.ResType;

                if (resIndex > -1)
                {
                    BuildSubRes subResource = buildSystem.BuildSubRes2.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;
                    }
                }

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

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

            CreateGroupList();

            if (page == BuildPage.PickResource)
            {
                CreateResList(false);
            }
            else if (page == BuildPage.PickResource2)
            {
                CreateResList(true);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                CreateItemList(context.LastGroupIndex);
            }
        }