ServUO Version
Publish 58
Ultima Expansion
Endless Journey
Does anyone have a pet that can be used for unraveling (for imbuing materials), they'd be willing to share ? Kind of like the fire beetle smelts.
 
Does anyone have a pet that can be used for unraveling (for imbuing materials), they'd be willing to share ? Kind of like the fire beetle smelts.
I dont believe that exists. I'm not super familiar with the programming behind it but wouldn't be difficult to copy the imbuing process to call Unraveling.
That way if you make any changes to Unraveling in the future you only make edits in one file vs. Two or more
 
I have an auto unravel built into my loot system to cut back on the amount of junk that gets dropped, feel free to use it.

Example of the way we have it setup, in LootPack.cs, changes are marked.
C#:
                        // Try to generate a new random item based on the creature killed
                        if (Core.HS && RandomItemGenerator.Enabled && from is BaseCreature)
                        {
                            if (RandomItemGenerator.GenerateRandomItem(item, ((BaseCreature)from).LastKiller, (BaseCreature)from))
                                //Iomega0318
                                item = AutoUnravel.Unravel(item);
                                return item;
                        }
C#:
        public Item Construct(bool inTokuno, bool isMondain, bool isStygian)
        {
            try
            {
                Item item;

                if (m_Type == typeof(BaseRanged))
                {
                    item = Loot.RandomRangedWeapon(inTokuno, isMondain, isStygian);
                }
                else if (m_Type == typeof(BaseWeapon))
                {
                    item = Loot.RandomWeapon(inTokuno, isMondain, isStygian);
                }
                else if (m_Type == typeof(BaseArmor))
                {
                    item = Loot.RandomArmorOrHat(inTokuno, isMondain, isStygian);
                }
                else if (m_Type == typeof(BaseShield))
                {
                    item = Loot.RandomShield(isStygian);
                }
                else if (m_Type == typeof(BaseJewel))
                {
                    item = Core.AOS ? Loot.RandomJewelry(isStygian) : Loot.RandomArmorOrShieldOrWeapon(isStygian);
                }
                else if (m_Type == typeof(BaseInstrument))
                {
                    item = Loot.RandomInstrument();
                }
                else if (m_Type == typeof(Amber)) // gem
                {
                    item = Loot.RandomGem();
                }
                // Iomega0318
                // socket lootpack drop mod
                else if (m_Type == typeof(BaseSocketAugmentation)) // socket augmentation
                {
                    item = Loot.RandomAugment();
                }
                else if (m_Type == typeof(ClumsyScroll)) // low scroll
                {
                    item = RandomScroll(1, 3);
                }
                else if (m_Type == typeof(ArchCureScroll)) // med scroll
                {
                    item = RandomScroll(4, 7);
                }
                else if (m_Type == typeof(SummonAirElementalScroll)) // high scroll
                {
                    item = RandomScroll(8, 8);
                }
                else
                {
                    item = Activator.CreateInstance(m_Type) as Item;
                }

                //Iomega0318
                item = AutoUnravel.Unravel(item);
                return item;
            }
            catch
            { }

            return null;
        }

Code:
C#:
using Server.Items;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Server.SkillHandlers
{
    class AutoUnravel
    {
        public static Item Unravel(Item item)
        {
            int weight = Imbuing.GetTotalWeight(item, -1, false, true);

            if (weight <= 0)
            {
                return item;
            }
            if (weight > 550)
            {
                if (item is IDurability d)
                {
                    //d.CanFortify = false;
                    if (d.MaxHitPoints > 50)
                    {
                        d.MaxHitPoints = 50;
                        d.HitPoints = 50;
                    }
                }
                item.LootType = LootType.Cursed;
                return item;
            }
            if (weight >= 400)
            {
                item.Delete();
                return new RelicFragment();
            }
            if (weight > 200)
            {
                item.Delete();
                return new EnchantedEssence();
            }
            else
            {
                item.Delete();
                return new MagicalResidue();
            }
        }
    }
}
 
I have an auto unravel built into my loot system to cut back on the amount of junk that gets dropped, feel free to use it.

Example of the way we have it setup, in LootPack.cs, changes are marked.
C#:
                        // Try to generate a new random item based on the creature killed
                        if (Core.HS && RandomItemGenerator.Enabled && from is BaseCreature)
                        {
                            if (RandomItemGenerator.GenerateRandomItem(item, ((BaseCreature)from).LastKiller, (BaseCreature)from))
                                //Iomega0318
                                item = AutoUnravel.Unravel(item);
                                return item;
                        }
C#:
        public Item Construct(bool inTokuno, bool isMondain, bool isStygian)
        {
            try
            {
                Item item;

                if (m_Type == typeof(BaseRanged))
                {
                    item = Loot.RandomRangedWeapon(inTokuno, isMondain, isStygian);
                }
                else if (m_Type == typeof(BaseWeapon))
                {
                    item = Loot.RandomWeapon(inTokuno, isMondain, isStygian);
                }
                else if (m_Type == typeof(BaseArmor))
                {
                    item = Loot.RandomArmorOrHat(inTokuno, isMondain, isStygian);
                }
                else if (m_Type == typeof(BaseShield))
                {
                    item = Loot.RandomShield(isStygian);
                }
                else if (m_Type == typeof(BaseJewel))
                {
                    item = Core.AOS ? Loot.RandomJewelry(isStygian) : Loot.RandomArmorOrShieldOrWeapon(isStygian);
                }
                else if (m_Type == typeof(BaseInstrument))
                {
                    item = Loot.RandomInstrument();
                }
                else if (m_Type == typeof(Amber)) // gem
                {
                    item = Loot.RandomGem();
                }
                // Iomega0318
                // socket lootpack drop mod
                else if (m_Type == typeof(BaseSocketAugmentation)) // socket augmentation
                {
                    item = Loot.RandomAugment();
                }
                else if (m_Type == typeof(ClumsyScroll)) // low scroll
                {
                    item = RandomScroll(1, 3);
                }
                else if (m_Type == typeof(ArchCureScroll)) // med scroll
                {
                    item = RandomScroll(4, 7);
                }
                else if (m_Type == typeof(SummonAirElementalScroll)) // high scroll
                {
                    item = RandomScroll(8, 8);
                }
                else
                {
                    item = Activator.CreateInstance(m_Type) as Item;
                }

                //Iomega0318
                item = AutoUnravel.Unravel(item);
                return item;
            }
            catch
            { }

            return null;
        }

Code:
C#:
using Server.Items;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Server.SkillHandlers
{
    class AutoUnravel
    {
        public static Item Unravel(Item item)
        {
            int weight = Imbuing.GetTotalWeight(item, -1, false, true);

            if (weight <= 0)
            {
                return item;
            }
            if (weight > 550)
            {
                if (item is IDurability d)
                {
                    //d.CanFortify = false;
                    if (d.MaxHitPoints > 50)
                    {
                        d.MaxHitPoints = 50;
                        d.HitPoints = 50;
                    }
                }
                item.LootType = LootType.Cursed;
                return item;
            }
            if (weight >= 400)
            {
                item.Delete();
                return new RelicFragment();
            }
            if (weight > 200)
            {
                item.Delete();
                return new EnchantedEssence();
            }
            else
            {
                item.Delete();
                return new MagicalResidue();
            }
        }
    }
}
Works like a charm! Thanks
 
Well you could also let it follow the default formula.

This is the code behind the unravel container, for example.
You can modify this how you want too.



C#:
                    int count = 0;

                    m_List.ForEach(item =>
                    {
                        if (Imbuing.CanUnravelItem(User, item, true) && Imbuing.UnravelItem(User, item, true))
                        {
                            count++;
                        }
                    });

                    if (count > 0)
                    {
                        User.SendLocalizedMessage(1080429); // You magically unravel the item!
                        User.SendLocalizedMessage(1072223); // An item has been placed in your backpack.
                    }

                    User.SendLocalizedMessage(1111814, String.Format("{0}\t{1}", count, m_List.Count));
 
Back