Exemple #1
0
 public void Add(CraftRes craftRes)
 {
     List.Add(craftRes);
 }
Exemple #2
0
 public void Add(CraftRes craftRes)
 {
     this.List.Add(craftRes);
 }
Exemple #3
0
        public void DrawRessource()
        {
            bool retainedColor = false;

            CraftContext context = m_CraftSystem.GetContext(m_From);

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

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

            for (int i = 0; i < m_CraftItem.Ressources.Count && i < 4; i++)
            {
                Type   type;
                string nameString;
                int    nameNumber;

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

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

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

                    type = subResource.ItemType;

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

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

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

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

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

            if (m_CraftItem.NameNumber == 1041267)               // runebook
            {
                AddHtmlLocalized(170, 219 + (m_CraftItem.Ressources.Count * 20), 310, 18, 1044447, LabelColor, false, false);
                AddLabel(430, 219 + (m_CraftItem.Ressources.Count * 20), LabelHue, "1");
            }
        }
Exemple #4
0
		public void AddRes( Type type, TextDefinition name, int amount, TextDefinition message )
		{
			CraftRes craftRes = new CraftRes( type, name, amount, message );
			m_arCraftRes.Add( craftRes );
		}
Exemple #5
0
        public CraftGumpItem(Mobile from, CraftSystem craftSystem, CraftItem craftItem, BaseTool tool)
            : base(50, 50)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_CraftItem   = craftItem;
            m_Tool        = tool;

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

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

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

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

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

            // Draw Item
            Type type = m_CraftItem.ItemType;

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

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

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

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

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

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

            // Draw Ressource
            bool retainedColor = false;

            CraftContext context = m_CraftSystem.GetContext(m_From);

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

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

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

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

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

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

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

                    _type = subResource.ItemType;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Draw Chances
            DrawChances();
            // ***********************************
        }
Exemple #6
0
		public void AddRes(Type type, string name, int amount, string strMessage)
		{
			CraftRes craftRes = new CraftRes(type, name, amount, strMessage);
			m_arCraftRes.Add(craftRes);
		}
		public virtual int OnCraft(
			int quality,
			bool makersMark,
			Mobile m,
			CraftSystem craftSystem,
			Type typeRes,
			//Compatibility with UOF fix
			IBaseTool tool,
			CraftItem craftItem,
			int resHue)
		{
			if (makersMark)
			{
				Crafter = m;
			}

			if (craftSystem is Pyrotechnics && craftItem != null)
			{
				CraftContext context = craftSystem.GetContext(m);

				if (context != null && !context.DoNotColor)
				{
					Hue = resHue;
				}

				CraftRes[] fuses = new CraftRes[craftItem.Resources.Count];
				fuses.SetAll(i => craftItem.Resources.GetAt(i));
				fuses = fuses.Where(res => res.ItemType.IsEqualOrChildOf<FireworkFuse>()).ToArray();

				double fuseDelay = FuseDelay.TotalSeconds * fuses.Sum(r => r.Amount);

				if (fuseDelay > 0)
				{
					FuseDelay = TimeSpan.FromSeconds(fuseDelay);
				}
			}

			return quality;
		}
Exemple #8
0
            private SmeltResult Resmelt(Mobile from, Item item, CraftResource resource)
            {
                try
                {
                    if (Ethic.IsImbued(item))
                    {
                        return(SmeltResult.Invalid);
                    }

                    if (CraftResources.GetType(resource) != CraftResourceType.Metal)
                    {
                        return(SmeltResult.Invalid);
                    }

                    CraftResourceInfo info = CraftResources.GetInfo(resource);

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

                    CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor(item.GetType());

                    if (craftItem == null || craftItem.Resources.Count == 0)
                    {
                        return(SmeltResult.Invalid);
                    }

                    CraftRes craftResource = craftItem.Resources.GetAt(0);

                    if (craftResource.Amount < 2)
                    {
                        return(SmeltResult.Invalid); // Not enough metal to resmelt
                    }
                    var difficulty = resource switch
                    {
                        CraftResource.DullCopper => 65.0,
                        CraftResource.ShadowIron => 70.0,
                        CraftResource.Copper => 75.0,
                        CraftResource.Bronze => 80.0,
                        CraftResource.Gold => 85.0,
                        CraftResource.Agapite => 90.0,
                        CraftResource.Verite => 95.0,
                        CraftResource.Valorite => 99.0,
                        _ => 0.0
                    };

                    if (difficulty > from.Skills.Mining.Value)
                    {
                        return(SmeltResult.NoSkill);
                    }

                    Type resourceType = info.ResourceTypes[0];
                    Item ingot        = (Item)Activator.CreateInstance(resourceType);

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

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

                    from.PlaySound(0x2A);
                    from.PlaySound(0x240);
                    return(SmeltResult.Success);
                }
Exemple #9
0
        private static bool DoResmelt(CraftSystem system, Mobile from, Item item, CraftResource resource, bool playSound)
        {
            try
            {
                if (CraftResources.GetType(resource) != CraftResourceType.Metal)
                {
                    return(false);
                }

                CraftResourceInfo info = CraftResources.GetInfo(resource);

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

                if (!CheckResourceSkill(info.Resource, from.Skills[SkillName.Mining].Value))
                {
                    return(false);
                }

                CraftItem craftItem = system.CraftItems.SearchFor(item.GetType());

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

                CraftRes craftResource = craftItem.Ressources.GetAt(0);

                if (craftResource.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 = craftResource.Amount / 2;
                }
                else
                {
                    ingot.Amount = 1;
                }

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

                if (playSound)
                {
                    from.PlaySound(0x2A);
                    from.PlaySound(0x240);
                }

                return(true);
            }
            catch
            {
            }

            return(false);
        }
            private RecycleResult Recycle(Mobile from, Item item)
            {
                if (from == null || item == null || m_CraftSystem == null || m_Tool == null)
                {
                    return(RecycleResult.Invalid);
                }

                if (from.Backpack == null)
                {
                    return(RecycleResult.Invalid);
                }

                CraftContext craftContext = m_CraftSystem.GetContext(from);

                if (craftContext == null)
                {
                    return(RecycleResult.Invalid);
                }

                bool recycleEntireBackpack = false;

                if (craftContext.RecycleOption == CraftRecycleOption.RecycleEverything && item == from.Backpack)
                {
                    recycleEntireBackpack = true;
                }

                List <CraftSystem> m_RecycleableCraftSystems = GetRecyclableCraftSystems();

                List <Type> m_ItemTypes = new List <Type>();

                if (recycleEntireBackpack)
                {
                    List <Item> m_BackpackItems = from.Backpack.FindItemsByType <Item>();

                    foreach (Item backpackItem in m_BackpackItems)
                    {
                        if (backpackItem is BaseTool)
                        {
                            continue;
                        }

                        Type itemType = backpackItem.GetType();

                        if (!m_ItemTypes.Contains(itemType))
                        {
                            m_ItemTypes.Add(itemType);
                        }
                    }
                }

                else
                {
                    m_ItemTypes.Add(item.GetType());
                }

                List <int> m_RecycleSounds = new List <int>();

                int deletedCount = 0;

                foreach (Type itemType in m_ItemTypes)
                {
                    foreach (CraftSystem craftSystem in m_RecycleableCraftSystems)
                    {
                        CraftItem craftItem = craftSystem.CraftItems.SearchFor(itemType);

                        if (craftItem == null || craftItem.Resources.Count == 0)
                        {
                            continue;
                        }

                        Dictionary <Type, int> m_ValidRecipeResources = new Dictionary <Type, int>();

                        CraftResCol craftResourceCollection = craftItem.Resources;

                        for (int a = 0; a < craftResourceCollection.Count; a++)
                        {
                            CraftRes craftResource = craftResourceCollection.GetAt(a);

                            if (!IsRecycleResource(craftResource.ItemType))
                            {
                                continue;
                            }

                            if (!m_ValidRecipeResources.ContainsKey(craftResource.ItemType))
                            {
                                m_ValidRecipeResources.Add(craftResource.ItemType, craftResource.Amount);
                            }
                        }

                        if (m_ValidRecipeResources.Count == 0)
                        {
                            continue;
                        }

                        List <Item> m_ItemMatches    = new List <Item>();
                        List <Item> m_ItemsToRecycle = new List <Item>();

                        Item[] m_MatchingItems = from.Backpack.FindItemsByType(itemType);

                        for (int a = 0; a < m_MatchingItems.Length; a++)
                        {
                            Item targetItem = m_MatchingItems[a];

                            if (craftContext.RecycleOption == CraftRecycleOption.RecycleSingle && targetItem == item)
                            {
                                m_ItemMatches.Add(targetItem);
                                continue;
                            }

                            if (craftContext.RecycleOption == CraftRecycleOption.RecycleRegularByType && targetItem.Quality == Quality.Regular && !targetItem.IsMagical)
                            {
                                m_ItemMatches.Add(targetItem);
                                continue;
                            }

                            if (craftContext.RecycleOption == CraftRecycleOption.RecycleExceptionalByType && targetItem.Quality == Quality.Exceptional)
                            {
                                m_ItemMatches.Add(targetItem);
                                continue;
                            }

                            if (craftContext.RecycleOption == CraftRecycleOption.RecycleExceptionalByType && targetItem.IsMagical)
                            {
                                m_ItemMatches.Add(targetItem);
                                continue;
                            }

                            if (craftContext.RecycleOption == CraftRecycleOption.RecycleAnyByType)
                            {
                                m_ItemMatches.Add(targetItem);
                                continue;
                            }

                            if (craftContext.RecycleOption == CraftRecycleOption.RecycleEverything)
                            {
                                m_ItemMatches.Add(targetItem);
                                continue;
                            }
                        }

                        foreach (Item recycleItem in m_ItemMatches)
                        {
                            if (!recycleItem.Movable)
                            {
                                continue;
                            }
                            if (recycleItem.LootType != LootType.Regular)
                            {
                                continue;
                            }
                            if (recycleItem.DecorativeEquipment)
                            {
                                continue;
                            }
                            if (recycleItem.TierLevel > 0 && recycleItem.Aspect != AspectEnum.None)
                            {
                                continue;
                            }
                            if (recycleItem is BaseContainer && recycleItem.TotalItems > 0)
                            {
                                continue;
                            }

                            m_ItemsToRecycle.Add(recycleItem);
                        }

                        if (m_ItemsToRecycle.Count == 0)
                        {
                            continue;
                        }

                        Queue m_Queue = new Queue();

                        foreach (Item recycleItem in m_ItemsToRecycle)
                        {
                            m_Queue.Enqueue(recycleItem);
                        }

                        while (m_Queue.Count > 0)
                        {
                            Item recycleItem = (Item)m_Queue.Dequeue();

                            bool deleteItem = false;

                            foreach (KeyValuePair <Type, int> pair in m_ValidRecipeResources)
                            {
                                double salvageScalar = .5;

                                if (recycleItem.ItemGroup != ItemGroupType.Crafted)
                                {
                                    salvageScalar = .25;
                                }

                                Type resourceType        = pair.Key;
                                int  totalResourceAmount = (int)(Math.Floor((double)pair.Value * (double)recycleItem.Amount * salvageScalar));

                                if (totalResourceAmount < 1)
                                {
                                    continue;
                                }

                                //Ingot
                                if (resourceType == typeof(IronIngot))
                                {
                                    if (!m_RecycleSounds.Contains(0x2A))
                                    {
                                        m_RecycleSounds.Add(0x2A);
                                    }

                                    if (!m_RecycleSounds.Contains(0x240))
                                    {
                                        m_RecycleSounds.Add(0x240);
                                    }

                                    if (recycleItem.Resource != CraftResource.Iron)
                                    {
                                        resourceType = CraftResources.GetCraftResourceType(recycleItem.Resource);

                                        if (resourceType == null)
                                        {
                                            resourceType = typeof(IronIngot);
                                        }
                                    }
                                }

                                //Leather
                                if (resourceType == typeof(Leather))
                                {
                                    if (!m_RecycleSounds.Contains(0x3E3))
                                    {
                                        m_RecycleSounds.Add(0x3E3);
                                    }

                                    if (recycleItem.Resource != CraftResource.RegularLeather)
                                    {
                                        resourceType = CraftResources.GetCraftResourceType(recycleItem.Resource);

                                        if (resourceType == null)
                                        {
                                            resourceType = typeof(Leather);
                                        }
                                    }
                                }

                                //Wood
                                if (resourceType == typeof(Board))
                                {
                                    if (!m_RecycleSounds.Contains(0x23D))
                                    {
                                        m_RecycleSounds.Add(0x23D);
                                    }

                                    if (recycleItem.Resource != CraftResource.RegularWood)
                                    {
                                        resourceType = CraftResources.GetCraftResourceType(recycleItem.Resource);

                                        if (resourceType == null)
                                        {
                                            resourceType = typeof(Board);
                                        }
                                    }
                                }

                                Item newResource = (Item)Activator.CreateInstance(resourceType);

                                if (newResource == null)
                                {
                                    continue;
                                }

                                //Cloth
                                if (resourceType == typeof(Cloth))
                                {
                                    if (!m_RecycleSounds.Contains(0x248))
                                    {
                                        m_RecycleSounds.Add(0x248);
                                    }

                                    newResource.Hue = recycleItem.Hue;
                                }

                                deleteItem = true;
                                deletedCount++;

                                newResource.Amount = totalResourceAmount;
                                from.AddToBackpack(newResource);
                            }

                            int arcaneEssenceValue = recycleItem.GetArcaneEssenceValue();

                            if (arcaneEssenceValue > 0)
                            {
                                ArcaneEssence arcaneEssenceItem = new ArcaneEssence(arcaneEssenceValue);
                                from.AddToBackpack(arcaneEssenceItem);
                            }

                            if (deleteItem)
                            {
                                recycleItem.Delete();
                            }
                        }
                    }
                }

                if (deletedCount > 0)
                {
                    foreach (int sound in m_RecycleSounds)
                    {
                        from.PlaySound(sound);
                    }

                    if (deletedCount > 1)
                    {
                        return(RecycleResult.SuccessMultiple);
                    }

                    else
                    {
                        return(RecycleResult.Success);
                    }
                }

                else
                {
                    if (recycleEntireBackpack)
                    {
                        return(RecycleResult.InvalidEntireBackpack);
                    }

                    else
                    {
                        return(RecycleResult.Invalid);
                    }
                }
            }
Exemple #11
0
            private SmeltResult Resmelt(Mobile from, Item item, CraftResource resource)
            {
                try
                {
                    if (Ethics.Ethic.IsImbued(item))
                    {
                        return(SmeltResult.Invalid);
                    }

                    if (CraftResources.GetType(resource) != CraftResourceType.Metal)
                    {
                        return(SmeltResult.Invalid);
                    }

                    CraftResourceInfo info = CraftResources.GetInfo(resource);

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

                    CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor(item.GetType());

                    if (craftItem == null || craftItem.Resources.Count == 0)
                    {
                        return(SmeltResult.Invalid);
                    }

                    CraftRes craftResource = craftItem.Resources.GetAt(0);

                    if (craftResource.Amount < 2)
                    {
                        return(SmeltResult.Invalid);                        // Not enough metal to resmelt
                    }
                    double difficulty = 0.0;

                    switch (resource)
                    {
                    case CraftResource.MRusty: difficulty = 50.0; break;

                    case CraftResource.MOldcopper: difficulty = 60.0; break;

                    case CraftResource.MDullcopper: difficulty = 65.0; break;

                    case CraftResource.MShadow: difficulty = 70.0; break;

                    case CraftResource.MCopper: difficulty = 75.0; break;

                    case CraftResource.MBronze: difficulty = 80.0; break;

                    case CraftResource.MGold: difficulty = 85.0; break;

                    case CraftResource.MRose: difficulty = 87.0; break;

                    case CraftResource.MAgapite: difficulty = 90.0; break;

                    case CraftResource.MValorite: difficulty = 90.0; break;

                    case CraftResource.MBloodrock: difficulty = 93.0; break;

                    case CraftResource.MVerite: difficulty = 95.0; break;

                    case CraftResource.MSilver: difficulty = 95.0; break;

                    case CraftResource.MDragon: difficulty = 95.0; break;

                    case CraftResource.MTitan: difficulty = 95.0; break;

                    case CraftResource.MCrystaline: difficulty = 95.0; break;

                    case CraftResource.MKrynite: difficulty = 95.0; break;

                    case CraftResource.MVulcan: difficulty = 95.0; break;

                    case CraftResource.MBloodcrest: difficulty = 95.0; break;

                    case CraftResource.MElvin: difficulty = 95.0; break;

                    case CraftResource.MAcid: difficulty = 95.0; break;

                    case CraftResource.MAqua: difficulty = 95.0; break;

                    case CraftResource.MEldar: difficulty = 95.0; break;

                    case CraftResource.MGlowing: difficulty = 95.0; break;

                    case CraftResource.MGorgan: difficulty = 95.0; break;

                    case CraftResource.MSteel: difficulty = 95.5; break;

                    case CraftResource.MSandrock: difficulty = 95.0; break;

                    case CraftResource.MMytheril: difficulty = 97.5; break;

                    case CraftResource.MBlackrock: difficulty = 98.0; break;
                    }

                    if (difficulty > from.Skills[SkillName.Mining].Value)
                    {
                        return(SmeltResult.NoSkill);
                    }

                    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 = craftResource.Amount / 2;
                    }
                    else
                    {
                        ingot.Amount = 1;
                    }

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

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

                return(SmeltResult.Invalid);
            }
Exemple #12
0
        public void DrawResource()
        {
            bool retainedColor = false;

            CraftContext context = m_CraftSystem.GetContext(m_From);

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

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

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

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

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

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

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

                    type = subResource.ItemType;

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

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

                if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, type))
                {
                    retainedColor = true;
                    AddHtml(170, 302 + (m_OtherCount++ *20), 300, 20, "<h3><basefont color=#FFFFFF>*  L'objet retient la couleur de ce matériel<basefont></h3>", false, false);
                    AddHtml(500, 219 + (i * 20), 20, 20, "<h3><basefont color=#FFFFFF>*<basefont></h3>", false, false);
                    //AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1044152, LabelColor, false, false ); // * The item retains the color of this material
                    //AddLabel( 500, 219 + (i * 20), LabelHue, "*" );
                }

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    //AddLabel( 170, 219 + (i * 20), LabelHue, nameString );
                    AddHtml(170, 219 + (i * 20), 300, 20, "<h3><basefont color=#FFFFFF>" + nameString + "<basefont></h3>", false, false);
                }

                AddHtml(480, 219 + (i * 20), 300, 20, "<h3><basefont color=#FFFFFF>" + craftResource.Amount.ToString() + "<basefont></h3>", false, false);
                //AddLabel( 430, 219 + (i * 20), LabelHue, craftResource.Amount.ToString() );
            }

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

            if (cropScroll)
            {
                AddHtml(170, 302 + (m_OtherCount++ *20), 300, 20, "<h3><basefont color=#FFFFFF>Les parchemins magiques nécessitent de la mana et un parchemin vierge.<basefont></h3>", false, false);
            }
            //AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 360, 18, 1044379, LabelColor, false, false ); // Inscribing scrolls also requires a blank scroll and mana.
        }
Exemple #13
0
            private SmeltResult Resmelt(Mobile from, Item item, CraftResource resource)
            {
                try
                {
                    if (CraftResources.GetType(resource) != CraftResourceType.Metal)
                    {
                        return(SmeltResult.Invalid);
                    }

                    CraftResourceInfo info = CraftResources.GetInfo(resource);

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

                    CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor(item.GetType());

                    if (craftItem == null || craftItem.Resources.Count == 0)
                    {
                        return(SmeltResult.Invalid);
                    }

                    CraftRes craftResource = craftItem.Resources.GetAt(0);

                    if (craftResource.Amount < 2)
                    {
                        return(SmeltResult.Invalid); // Not enough metal to resmelt
                    }
                    double difficulty = 0.0;

                    switch (resource)
                    {
                    case CraftResource.DullCopper: difficulty = 65.0; break;

                    case CraftResource.ShadowIron: difficulty = 70.0; break;

                    case CraftResource.Copper: difficulty = 75.0; break;

                    case CraftResource.Bronze: difficulty = 80.0; break;

                    case CraftResource.Gold: difficulty = 85.0; break;

                    case CraftResource.Agapite: difficulty = 90.0; break;

                    case CraftResource.Verite: difficulty = 95.0; break;

                    case CraftResource.Valorite: difficulty = 99.0; break;
                    }

                    if (difficulty > from.Skills[SkillName.Mining].Value)
                    {
                        return(SmeltResult.NoSkill);
                    }

                    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 = craftResource.Amount / 2;
                    }
                    else
                    {
                        ingot.Amount = 1;
                    }

                    if (item.Amount > 1)
                    {
                        item.Amount--;
                    }
                    else
                    {
                        item.Delete();
                    }

                    #region Add to pack or ground if overweight
                    //Taran: Check to see if player is overweight. If they are and the item drops to the
                    //ground then a check is made to see if it can be stacked. If it can't and  more than
                    //20 items of the same type exist in the same tile then the last item gets removed. This
                    //check is made so thousands of items can't exist in 1 tile and crash people in the same area.
                    if (from.AddToBackpack(ingot))
                    {
                        from.SendAsciiMessage("You put the {0} in your pack.", ingot.Name ?? CliLoc.LocToString(ingot.LabelNumber));
                    }
                    else if (!ingot.Deleted)
                    {
                        IPooledEnumerable eable = from.Map.GetItemsInRange(from.Location, 0);
                        int  amount             = 0;
                        Item toRemove           = null;

                        foreach (Item i in eable)
                        {
                            if (i != ingot && i.ItemID == ingot.ItemID)
                            {
                                if (i.StackWith(from, ingot, false))
                                {
                                    toRemove = ingot;
                                    break;
                                }

                                amount++;
                            }
                        }

                        from.SendAsciiMessage("You are overweight and put the {0} on the ground.", ingot.Name ?? CliLoc.LocToString(ingot.LabelNumber));

                        if (toRemove != null)
                        {
                            toRemove.Delete();
                        }

                        else if (amount >= 5 && amount < 20)
                        {
                            from.LocalOverheadMessage(MessageType.Regular, 906, true, string.Format("{0} identical items on the ground detected, no more than 20 is allowed!", amount));
                        }

                        else if (amount >= 20)
                        {
                            from.LocalOverheadMessage(MessageType.Regular, 906, true, "Too many identical items on the ground, removing!");
                            ingot.Delete();
                        }

                        eable.Free();
                    }
                    #endregion

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

                return(SmeltResult.Invalid);
            }
Exemple #14
0
            private RecycleResult Recycle(Mobile from, Item item)
            {
                if (from == null || item == null || m_CraftSystem == null || m_Tool == null)
                {
                    return(RecycleResult.Invalid);
                }

                CraftContext craftContext = m_CraftSystem.GetContext(from);

                if (craftContext == null)
                {
                    return(RecycleResult.Invalid);
                }

                Type itemType = item.GetType();

                CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor(itemType);

                if (craftItem == null || craftItem.Resources.Count == 0)
                {
                    return(RecycleResult.Invalid);
                }

                Dictionary <Type, int> m_ValidRecipeResources = new Dictionary <Type, int>();

                CraftResCol craftResourceCollection = craftItem.Resources;

                for (int a = 0; a < craftResourceCollection.Count; a++)
                {
                    CraftRes craftResource = craftResourceCollection.GetAt(a);

                    if (!IsRecycleResource(craftResource.ItemType))
                    {
                        continue;
                    }

                    if (!m_ValidRecipeResources.ContainsKey(craftResource.ItemType))
                    {
                        m_ValidRecipeResources.Add(craftResource.ItemType, craftResource.Amount);
                    }
                }

                if (m_ValidRecipeResources.Count == 0)
                {
                    return(RecycleResult.Invalid);
                }

                if (from.Backpack == null)
                {
                    return(RecycleResult.Invalid);
                }

                else if (from.Backpack.Deleted)
                {
                    return(RecycleResult.Invalid);
                }

                List <Item> m_Items          = new List <Item>();
                List <Item> m_ItemsToRecycle = new List <Item>();

                Item[] m_MatchingItems = from.Backpack.FindItemsByType(itemType);

                for (int a = 0; a < m_MatchingItems.Length; a++)
                {
                    Item targetItem = m_MatchingItems[a];

                    if (craftContext.RecycleOption == CraftRecycleOption.RecycleItem && targetItem == item)
                    {
                        m_ItemsToRecycle.Add(targetItem);
                        continue;
                    }

                    if (craftContext.RecycleOption == CraftRecycleOption.RecycleAllNonExceptional && targetItem.Quality != Quality.Exceptional)
                    {
                        m_Items.Add(targetItem);
                        continue;
                    }

                    if (craftContext.RecycleOption == CraftRecycleOption.RecycleAll)
                    {
                        m_ItemsToRecycle.Add(targetItem);
                        continue;
                    }
                }

                foreach (Item recycleItem in m_Items)
                {
                    if (recycleItem.LootType != LootType.Regular)
                    {
                        continue;
                    }
                    if (recycleItem.PlayerClassCurrencyValue > 0)
                    {
                        continue;
                    }
                    if (recycleItem.QuestItem)
                    {
                        continue;
                    }
                    if (recycleItem.Nontransferable)
                    {
                        continue;
                    }
                    if (recycleItem.DonationItem)
                    {
                        continue;
                    }
                    if (recycleItem.DecorativeEquipment)
                    {
                        continue;
                    }

                    m_ItemsToRecycle.Add(recycleItem);
                }

                if (m_ItemsToRecycle.Count == 0)
                {
                    return(RecycleResult.Invalid);
                }

                Queue m_Queue = new Queue();

                foreach (Item recycleItem in m_ItemsToRecycle)
                {
                    m_Queue.Enqueue(recycleItem);
                }

                int deletedCount = 0;

                List <int> m_RecycleSounds = new List <int>();

                while (m_Queue.Count > 0)
                {
                    Item recycleItem = (Item)m_Queue.Dequeue();

                    bool deleteItem = false;

                    foreach (KeyValuePair <Type, int> pair in m_ValidRecipeResources)
                    {
                        Type resourceType        = pair.Key;
                        int  totalResourceAmount = pair.Value * recycleItem.Amount;

                        if (totalResourceAmount < 2)
                        {
                            continue;
                        }

                        //Ingot
                        if (resourceType == typeof(IronIngot))
                        {
                            if (!m_RecycleSounds.Contains(0x2A))
                            {
                                m_RecycleSounds.Add(0x2A);
                            }

                            if (!m_RecycleSounds.Contains(0x240))
                            {
                                m_RecycleSounds.Add(0x240);
                            }

                            if (recycleItem.Resource != CraftResource.Iron)
                            {
                                resourceType = CraftResources.GetCraftResourceType(recycleItem.Resource);

                                if (resourceType == null)
                                {
                                    resourceType = typeof(IronIngot);
                                }
                            }
                        }

                        //Leather
                        if (resourceType == typeof(Leather))
                        {
                            if (!m_RecycleSounds.Contains(0x3E3))
                            {
                                m_RecycleSounds.Add(0x3E3);
                            }

                            if (recycleItem.Resource != CraftResource.RegularLeather)
                            {
                                resourceType = CraftResources.GetCraftResourceType(recycleItem.Resource);

                                if (resourceType == null)
                                {
                                    resourceType = typeof(Leather);
                                }
                            }
                        }

                        //Wood
                        if (resourceType == typeof(Board))
                        {
                            if (!m_RecycleSounds.Contains(0x23D))
                            {
                                m_RecycleSounds.Add(0x23D);
                            }

                            if (recycleItem.Resource != CraftResource.RegularWood)
                            {
                                resourceType = CraftResources.GetCraftResourceType(recycleItem.Resource);

                                if (resourceType == null)
                                {
                                    resourceType = typeof(Board);
                                }
                            }
                        }

                        Item newResource = (Item)Activator.CreateInstance(resourceType);

                        if (newResource == null)
                        {
                            continue;
                        }

                        //Cloth
                        if (resourceType == typeof(Cloth))
                        {
                            if (!m_RecycleSounds.Contains(0x248))
                            {
                                m_RecycleSounds.Add(0x248);
                            }

                            newResource.Hue = recycleItem.Hue;
                        }

                        deleteItem = true;
                        deletedCount++;

                        newResource.Amount = (int)(Math.Floor((double)totalResourceAmount / 2));
                        from.AddToBackpack(newResource);
                    }

                    int arcaneEssenceValue = recycleItem.GetArcaneEssenceValue();

                    if (arcaneEssenceValue > 0)
                    {
                        ArcaneEssence arcaneEssenceItem = new ArcaneEssence(arcaneEssenceValue);
                        from.AddToBackpack(arcaneEssenceItem);
                    }

                    if (deleteItem)
                    {
                        recycleItem.Delete();
                    }
                }

                if (deletedCount > 0)
                {
                    foreach (int sound in m_RecycleSounds)
                    {
                        from.PlaySound(sound);
                    }

                    return(RecycleResult.Success);
                }

                else
                {
                    return(RecycleResult.Invalid);
                }
            }
Exemple #15
0
        public void DrawResource()
        {
            bool retainedColor = false;

            CraftContext context = m_CraftSystem.GetContext(m_From);

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

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

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

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

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

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

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

                    type = subResource.ItemType;

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

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

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

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

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

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

            if (cropScroll)
            {
                AddHtmlLocalized(170, 302 + m_OtherCount++ *20, 360, 18, 1044379, LabelColor, false, false);                    // Inscribing scrolls also requires a blank scroll and mana.
            }
        }
Exemple #16
0
            private SmeltResult Resmelt(Mobile from, Item item, CraftResource resource)
            {
                try
                {
                    if (Ethics.Ethic.IsImbued(item))
                    {
                        return(SmeltResult.Invalid);
                    }

                    if (CraftResources.GetType(resource) != CraftResourceType.Metal)
                    {
                        return(SmeltResult.Invalid);
                    }

                    CraftResourceInfo info = CraftResources.GetInfo(resource);

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

                    CraftItem craftItem = this.m_CraftSystem.CraftItems.SearchFor(item.GetType());

                    if (craftItem == null || craftItem.Resources.Count == 0)
                    {
                        return(SmeltResult.Invalid);
                    }

                    CraftRes craftResource = craftItem.Resources.GetAt(0);

                    if (craftResource.Amount < 2)
                    {
                        return(SmeltResult.Invalid); // Not enough metal to resmelt
                    }
                    //daat99 OWLTR start - smelting difficulty
                    double difficulty = daat99.ResourceHelper.GetMinSkill(resource);
                    //daat99 OWLTR end - smelting difficulty

                    // double difficulty = 0.0;

                    // switch ( resource )
                    // {
                    // case CraftResource.DullCopper:
                    // difficulty = 65.0;
                    // break;
                    // case CraftResource.ShadowIron:
                    // difficulty = 70.0;
                    // break;
                    // case CraftResource.Copper:
                    // difficulty = 75.0;
                    // break;
                    // case CraftResource.Bronze:
                    // difficulty = 80.0;
                    // break;
                    // case CraftResource.Gold:
                    // difficulty = 85.0;
                    // break;
                    // case CraftResource.Agapite:
                    // difficulty = 90.0;
                    // break;
                    // case CraftResource.Verite:
                    // difficulty = 95.0;
                    // break;
                    // case CraftResource.Valorite:
                    // difficulty = 99.0;
                    // break;
                    // }

                    if (difficulty > from.Skills[SkillName.Mining].Value)
                    {
                        return(SmeltResult.NoSkill);
                    }

                    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 = craftResource.Amount / 2;
                    }
                    else
                    {
                        ingot.Amount = 1;
                    }

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

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

                return(SmeltResult.Invalid);
            }
Exemple #17
0
		public void AddRes(Type type, int name, int amount, int localizedMessage)
		{
			CraftRes craftRes = new CraftRes(type, name, amount, localizedMessage);
			m_arCraftRes.Add(craftRes);
		}
Exemple #18
0
            private SmeltResult Resmelt(Mobile from, Item item, CraftResource resource)
            {
                try
                {
                    if (CraftResources.GetType(resource) != CraftResourceType.Metal)
                    {
                        return(SmeltResult.Invalid);
                    }

                    CraftResourceInfo info = CraftResources.GetInfo(resource);

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

                    CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor(item.GetType());

                    if (craftItem == null || craftItem.Resources.Count == 0)
                    {
                        return(SmeltResult.Invalid);
                    }

                    CraftRes craftResource = craftItem.Resources.GetAt(0);

                    if (craftResource.Amount < 2)
                    {
                        return(SmeltResult.Invalid); // Not enough metal to resmelt
                    }
                    double difficulty = 0.0;

                    switch (resource)
                    {
                    case CraftResource.DullCopper:
                        difficulty = 65.0;
                        break;

                    case CraftResource.ShadowIron:
                        difficulty = 70.0;
                        break;

                    case CraftResource.Copper:
                        difficulty = 75.0;
                        break;

                    case CraftResource.Bronze:
                        difficulty = 80.0;
                        break;

                    case CraftResource.Gold:
                        difficulty = 85.0;
                        break;

                    case CraftResource.Agapite:
                        difficulty = 90.0;
                        break;

                    case CraftResource.Verite:
                        difficulty = 95.0;
                        break;

                    case CraftResource.Valorite:
                        difficulty = 99.0;
                        break;
                    }

                    double skill = Math.Max(from.Skills[SkillName.Mining].Value, from.Skills[SkillName.Blacksmith].Value);

                    if (difficulty > skill)
                    {
                        return(SmeltResult.NoSkill);
                    }

                    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 = (int)(craftResource.Amount * .66);
                    }
                    else
                    {
                        ingot.Amount = 1;
                    }

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

                    from.PlaySound(0x2A);
                    from.PlaySound(0x240);
                    return(SmeltResult.Success);
                }
                catch (Exception e)
                {
                    Diagnostics.ExceptionLogging.LogException(e);
                }

                return(SmeltResult.Invalid);
            }
Exemple #19
0
 public void Add(CraftRes craftRes)
 {
     this.List.Add(craftRes);
 }
Exemple #20
0
        public bool ConsumeRes(Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message, bool isFailure)
        {
            Container ourPack = from.Backpack;

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

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

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

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

            maxAmount = int.MaxValue;

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

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

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

                    CraftSubRes subResource = resCol.SearchFor(baseType);

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

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

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

                /*if ( !retainedColor && RetainsColorFrom( craftSystem, baseType ) )
                 * {
                 *      retainedColor = true;
                 *      Item resItem = ourPack.FindItemByType( types[i] );
                 *
                 *      if ( resItem != null )
                 *              resHue = resItem.Hue;
                 * }*/

                amounts[i] = craftRes.Amount;

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

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

                            if (res.MessageNumber > 0)
                            {
                                message = res.MessageNumber;
                            }
                            else if (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);
                        }
                    }
                }
                // ****************************

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

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

            Item consumeExtra = null;

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

                Item[] runes = ourPack.FindItemsByType(typeof(RecallRune));

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

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

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

            int index = 0;

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

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

                resHue = m_ResHue;
            }

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

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

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

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

                resHue = m_ResHue;
            }

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

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

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

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

                if (res.MessageNumber > 0)
                {
                    message = res.MessageNumber;
                }
                else if (res.MessageString != null && res.MessageString != String.Empty)
                {
                    message = res.MessageString;
                }
                else
                {
                    message = 502925;                     // You don't have the resources required to make that item.
                }
                return(false);
            }
        }
	    public void Add( CraftRes craftRes )
		{
			List.Add( craftRes );
		}
Exemple #22
0
        public void AddRes(Type type, TextDefinition name, int amount, TextDefinition message)
        {
            CraftRes craftRes = new CraftRes(type, name, amount, message);

            m_arCraftRes.Add(craftRes);
        }
		public override int OnCraft(
			int quality,
			bool makersMark,
			Mobile m,
			CraftSystem craftSystem,
			Type typeRes,
			//Compatibility with UOF fix
			IBaseTool tool,
			CraftItem craftItem,
			int resHue)
		{
			if (craftSystem is Pyrotechnics && craftItem != null)
			{
				CraftRes[] stars = new CraftRes[craftItem.Resources.Count];
				stars.SetAll(i => craftItem.Resources.GetAt(i));
				stars = stars.Where(res => res.ItemType.IsEqualOrChildOf<BaseFireworkStar>()).ToArray();
				
				if (stars.Length > 0)
				{
					StarsRangeMin = 1 + stars.Sum(s => s.Amount);
					StarsRangeMax = StarsRangeMin * 2;

					LaunchHeightMin = Math.Max(50, Math.Min(100, StarsRangeMin * 5));
					LaunchHeightMax = Math.Max(50, Math.Min(100, StarsRangeMax * 5));

					StarHues.AddRange(BaseFireworkStar.GetEffectHues(typeRes ?? stars[0].ItemType));

					if (stars.Length > 1)
					{
						StarHues.AddRange(stars.Skip(1).SelectMany(s => BaseFireworkStar.GetEffectHues(s.ItemType)));
					}
				}
			}

			return base.OnCraft(quality, makersMark, m, craftSystem, typeRes, tool, craftItem, resHue);
		}
Exemple #24
0
        public void DrawRessource()
        {
            bool retainedColor = false;

            CraftContext context = m_CraftSystem.GetContext(m_From);

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

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

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

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

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

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

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

                    type = subResource.ItemType;

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

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

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

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

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

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

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

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

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

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

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