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.
            }
        }
        public QueryMakersMarkGump(int quality, Mobile from, BuildItem buildItem, BuildSystem buildSystem, Type typeRes, BaseBuildingTool tool) : base(100, 200)
        {
            from.CloseGump(typeof(QueryMakersMarkGump));

            m_Quality     = quality;
            m_From        = from;
            m_BuildItem   = buildItem;
            m_BuildSystem = buildSystem;
            m_TypeRes     = typeRes;
            m_Tool        = tool;

            AddPage(0);

            AddBackground(0, 0, 220, 170, 5054);
            AddBackground(10, 10, 200, 150, 3000);

            AddHtmlLocalized(20, 20, 180, 80, 1018317, false, false);               // Do you wish to place your maker's mark on this item?

            AddHtmlLocalized(55, 100, 140, 25, 1011011, false, false);              // CONTINUE
            AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0);

            AddHtmlLocalized(55, 125, 140, 25, 1011012, false, false);               // CANCEL
            AddButton(20, 125, 4005, 4007, 0, GumpButtonType.Reply, 0);
        }
Example #3
0
 public InternalTarget(BuildSystem buildSystem, BaseBuildingTool tool) :  base(2, false, TargetFlags.None)
 {
     m_BuildSystem = buildSystem;
     m_Tool        = tool;
 }
        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
            }
        }
 public bool CheckLokaiSkills(Mobile from, Type typeRes, BuildSystem buildSystem, ref int quality, ref bool allRequiredLokaiSkills)
 {
     return(CheckLokaiSkills(from, typeRes, buildSystem, ref quality, ref allRequiredLokaiSkills, true));
 }
        public bool ConsumeRes(Mobile from, Type typeRes, BuildSystem buildSystem, 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);
            }

            if (m_NeedWoodworker && !Find(from, m_WoodworkersBench))
            {
                message = "You must be near a woodworker's bench to do that.";
                return(false);
            }

            if (m_NeedCooper && !Find(from, m_CoopersBench))
            {
                message = "You must be near a cooper's bench to do that.";
                return(false);
            }

            if (m_NeedForeman && !Find(from, typeof(Foreman), 3))
            {
                message = "You must be near a foreman to do that.";
                return(false);
            }

            if (m_arBuildRes.Count == 0)
            {
                message = "Resource count is 0?";
                return(false);
            }

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

            maxAmount = int.MaxValue;

            BuildSubResCol resCol = (m_UseSubRes2 ? buildSystem.BuildSubRes2 : buildSystem.BuildSubRes);

            for (int i = 0; i < types.Length; ++i)
            {
                BuildRes buildRes = m_arBuildRes.GetAt(i);
                Type     baseType = buildRes.ItemType;

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

                    BuildSubRes subResource = resCol.SearchFor(baseType);

                    if (subResource != null && LokaiSkillUtilities.XMLGetSkills(from)[buildSystem.MainLokaiSkill].Base < subResource.RequiredLokaiSkill)
                    {
                        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] = buildRes.Amount;

                // For stackable items that can be built 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)
                        {
                            BuildRes res = m_arBuildRes.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 && !buildSystem.ConsumeOnFailure(from, types[i][0], this))
                {
                    amounts[i] = 0;
                }
            }

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

            int index = 0;

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

                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 build 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 = buildSystem;

                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 builder 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)
            {
                return(true);
            }
            else
            {
                BuildRes res = m_arBuildRes.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);
            }
        }
 public bool ConsumeRes(Mobile from, Type typeRes, BuildSystem buildSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message)
 {
     return(ConsumeRes(from, typeRes, buildSystem, ref resHue, ref maxAmount, consumeType, ref message, false));
 }
 public bool RetainsColorFrom(BuildSystem system, Type type)
 {
     return(false);
 }
 public static void Do(Mobile from, BuildSystem buildSystem, RepairDeed deed)
 {
     from.Target = new InternalTarget(buildSystem, deed);
     from.SendLocalizedMessage(1044276);               // Target an item to repair.
 }
        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;
            }
            }
        }
        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);
            }
        }
        /*public BuildGump( Mobile from, BuildSystem buildSystem, BaseBuildingTool tool ): this( from, buildSystem, -1, -1, tool, null )
         * {
         * }*/

        public BuildGump(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool, object notice) : this(from, buildSystem, tool, notice, BuildPage.None)
        {
        }
Example #13
0
        public BuildGumpItem(Mobile from, BuildSystem buildSystem, BuildItem buildItem, BaseBuildingTool tool) : base(40, 40)
        {
            m_From        = from;
            m_BuildSystem = buildSystem;
            m_BuildItem   = buildItem;
            m_Tool        = tool;

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

            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, 217, 150, 53, 2624);
            AddImageTiled(165, 132, 355, 80, 2624);
            AddImageTiled(10, 275, 155, 22, 2624);
            AddImageTiled(10, 302, 150, 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, 399);

            AddHtmlLocalized(170, 40, 150, 20, 1044053, LabelColor, false, false);                                // ITEM
            AddHtmlLocalized(10, 192, 150, 22, 1070722, "<CENTER>ABILITIIES</CENTER>", LabelColor, false, false); // ABILITIIES
            //AddHtmlLocalized(10, 192, 150, 22, 1060857, LabelColor, false, false); // Primary LokaiSkill
            AddHtmlLocalized(10, 277, 150, 22, 1044055, LabelColor, false, false);                                // <CENTER>MATERIALS</CENTER>
            AddHtmlLocalized(10, 362, 150, 22, 1044056, LabelColor, false, false);                                // <CENTER>OTHER</CENTER>

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

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

            bool needsRecipe = false;

            if (needsRecipe)
            {
                AddButton(270, 387, 4005, 4007, 0, GumpButtonType.Page, 0);
                AddHtmlLocalized(305, 390, 150, 18, 1044151, GreyLabelColor, false, false);                   // MAKE NOW
            }
            else
            {
                AddButton(270, 387, 4005, 4007, 1, GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 390, 150, 18, 1044151, LabelColor, false, false);                   // MAKE NOW
            }

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

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

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

            if (buildItem.RequiredExpansion != Expansion.None)
            {
                bool supportsEx = (from.NetState != null && from.NetState.SupportsExpansion(buildItem.RequiredExpansion));
                TextDefinition.AddHtmlText(this, 170, 302 + (m_OtherCount++ *20), 310, 18, RequiredExpansionMessage(buildItem.RequiredExpansion), false, false, supportsEx ? LabelColor : RedLabelColor, supportsEx ? LabelHue : RedLabelHue);
            }

            if (needsRecipe)
            {
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1073620, RedLabelColor, false, false);                    // You have not learned this recipe.
            }
        }
Example #14
0
 public InternalTarget(BuildSystem buildSystem, RepairDeed deed) : base(2, false, TargetFlags.None)
 {
     m_BuildSystem = buildSystem;
     m_Deed        = deed;
 }
 public static EnhanceResult Invoke(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool, Item item, BuildResource resource, Type resType, ref object resMessage)
 {
     return(EnhanceResult.BadItem);
 }
        public void CompleteBuild(int quality, bool makersMark, Mobile from, BuildSystem buildSystem, Type typeRes, BaseBuildingTool tool, CustomBuild customBuild)
        {
            int badBuild = buildSystem.CanBuild(from, tool, m_Type);

            if (badBuild > 0)
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, badBuild));
                }
                else
                {
                    from.SendLocalizedMessage(badBuild);
                }

                return;
            }

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

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

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

                return;
            }

            bool toolBroken = false;

            int ignored    = 1;
            int endquality = 1;

            bool allRequiredLokaiSkills = true;

            if (CheckLokaiSkills(from, typeRes, buildSystem, ref ignored, ref allRequiredLokaiSkills))
            {
                // Resource
                int resHue    = 0;
                int maxAmount = 0;

                object message = null;

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

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

                    return;
                }

                tool.UsesRemaining--;

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

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

                int num = 0;

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

                if (item != null)
                {
                    if (item is IBuildable)
                    {
                        endquality = ((IBuildable)item).OnBuild(quality, makersMark, from, buildSystem, typeRes, tool, this, resHue);
                    }
                    else if (item.Hue == 0)
                    {
                        item.Hue = resHue;
                    }

                    if (maxAmount > 0)
                    {
                        item.Amount = maxAmount;
                    }

                    from.AddToBackpack(item);

                    if (from.AccessLevel > AccessLevel.Player)
                    {
                        CommandLogging.WriteLine(from, "Building {0} with build system {1}", CommandLogging.Format(item), buildSystem.GetType().Name);
                    }

                    //from.PlaySound( 0x57 );
                }

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

                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, num));
                }
                else if (num > 0)
                {
                    from.SendLocalizedMessage(num);
                }
            }
            else if (!allRequiredLokaiSkills)
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, 1044153));
                }
                else
                {
                    from.SendLocalizedMessage(1044153);                       // You don't have the required lokaiSkills to attempt this item.
                }
            }
            else
            {
                ConsumeType consumeType = (UseAllRes ? ConsumeType.Half : ConsumeType.All);
                int         resHue      = 0;
                int         maxAmount   = 0;

                object message = null;

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

                    return;
                }

                tool.UsesRemaining--;

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

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

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

                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, num));
                }
                else if (num > 0)
                {
                    from.SendLocalizedMessage(num);
                }
            }
        }
Example #17
0
 public static void Do(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool)
 {
     from.Target = new InternalTarget(buildSystem, tool);
     from.SendLocalizedMessage(1044276);               // Target an item to repair.
 }