Пример #1
0
        public void BuildItem(BuildItem item)
        {
            int num = m_BuildSystem.CanBuild(m_From, m_Tool, item.ItemType);

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

                BuildContext context = m_BuildSystem.GetContext(m_From);

                if (context != null)
                {
                    BuildSubResCol res      = (item.UseSubRes2 ? m_BuildSystem.BuildSubRes2 : m_BuildSystem.BuildSubRes);
                    int            resIndex = (item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

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

                m_BuildSystem.CreateItem(m_From, item.ItemType, type, m_Tool, item);
            }
        }
Пример #2
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));
            }
        }
        public BuildSystem(int minBuildEffect, int maxBuildEffect, double delay)
        {
            m_MinBuildEffect = minBuildEffect;
            m_MaxBuildEffect = maxBuildEffect;
            m_Delay          = delay;

            m_BuildItems   = new BuildItemCol();
            m_BuildGroups  = new BuildGroupCol();
            m_BuildSubRes  = new BuildSubResCol();
            m_BuildSubRes2 = new BuildSubResCol();

            InitBuildList();
        }
Пример #4
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);
                }
            }
        }
Пример #5
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.
            }
        }
Пример #6
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            // Back Button
            if (info.ButtonID == 0)
            {
                BuildGump buildGump = new BuildGump(m_From, m_BuildSystem, m_Tool, null);
                m_From.SendGump(buildGump);
            }
            else             // Make Button
            {
                int num = m_BuildSystem.CanBuild(m_From, m_Tool, m_BuildItem.ItemType);

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

                    BuildContext context = m_BuildSystem.GetContext(m_From);

                    if (context != null)
                    {
                        BuildSubResCol res      = (m_BuildItem.UseSubRes2 ? m_BuildSystem.BuildSubRes2 : m_BuildSystem.BuildSubRes);
                        int            resIndex = (m_BuildItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

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

                    m_BuildSystem.CreateItem(m_From, m_BuildItem.ItemType, type, m_Tool, m_BuildItem);
                }
            }
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
        public void DrawRessource()
        {
            bool retainedColor = false;

            BuildContext context = m_BuildSystem.GetContext(m_From);

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

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

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

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

                BuildRes buildResource = m_BuildItem.Ressources.GetAt(i);

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

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

                    type = subResource.ItemType;

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

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

                if (!retainedColor && m_BuildItem.RetainsColorFrom(m_BuildSystem, 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, buildResource.Amount.ToString());
            }

            if (m_BuildItem.NameNumber == 1041267)               // runebook
            {
                AddHtmlLocalized(170, 219 + (m_BuildItem.Ressources.Count * 20), 310, 18, 1044447, LabelColor, false, false);
                AddLabel(430, 219 + (m_BuildItem.Ressources.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.
            }
        }