Example #1
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.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);
            }