Пример #1
0
            private bool Resmelt(Mobile from, Item item, BuildResource resource)
            {
                try
                {
                    if (BuildResources.GetType(resource) != BuildResourceType.BasePieces)
                    {
                        return(false);
                    }

                    BuildResourceInfo info = BuildResources.GetInfo(resource);

                    if (info == null || info.ResourceTypes.Length == 0)
                    {
                        return(false);
                    }

                    BuildItem buildItem = m_BuildSystem.BuildItems.SearchFor(item.GetType());

                    if (buildItem == null || buildItem.Ressources.Count == 0)
                    {
                        return(false);
                    }

                    BuildRes buildResource = buildItem.Ressources.GetAt(0);

                    if (buildResource.Amount < 2)
                    {
                        return(false);                        // Not enough metal to resmelt
                    }
                    Type resourceType = info.ResourceTypes[0];
                    Item ingot        = (Item)Activator.CreateInstance(resourceType);

                    if (item is DragonBardingDeed || (item is BaseArmor && ((BaseArmor)item).PlayerConstructed) || (item is BaseWeapon && ((BaseWeapon)item).PlayerConstructed) || (item is BaseClothing && ((BaseClothing)item).PlayerConstructed))
                    {
                        ingot.Amount = buildResource.Amount / 2;
                    }
                    else
                    {
                        ingot.Amount = 1;
                    }

                    item.Delete();
                    from.AddToBackpack(ingot);

                    from.PlaySound(0x2A);
                    from.PlaySound(0x240);
                    return(true);
                }
                catch
                {
                }

                return(false);
            }
 public void Add(BuildRes buildRes)
 {
     List.Add(buildRes);
 }
Пример #3
0
        public void AddRes(Type type, TextDefinition name, int amount, TextDefinition message)
        {
            BuildRes buildRes = new BuildRes(type, name, amount, message);

            m_arBuildRes.Add(buildRes);
        }
Пример #4
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);
            }
        }
Пример #5
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.
            }
        }