[0.10.25] Enchanted Weapons And Armor Broken From Combat Break But Don't Disappear

Curated user bug reports with enough information to reproduce problem. Moderators will move topics here from Help & Support once a bug has been confirmed and enough information has been provided.
Post Reply
User avatar
Magicono43
Posts: 461
Joined: Tue Nov 06, 2018 7:06 am

[0.10.25] Enchanted Weapons And Armor Broken From Combat Break But Don't Disappear

Post by Magicono43 » Fri Jul 24, 2020 11:59 pm

So as usual, I was testing stuff while working on a mod. I noticed that enchanted weapons and armor don't get "destroyed" when they break, which was especially weird when it also occurs with items that have a trapped soul, they just become a broken enchanted item in the player's inventory that can be repaired like a normal item if you have "repair magic items" enabled.

The issue here is that there is some inconsistent behavior here, if you have the same enchanted item, and have a "On Use" effect on it, if you break the item through the "On Use" spell, the item WILL be destroyed and removed entirely from the inventory.

So I figured out why this is, the method used to decrease condition damage of Weapons and Armor from physical combat does not discriminate between magic and non-magic items, so no matter what item is having it's condition reduced from combat, it is automatically assumed to be a "normal" item that follows the same rules when they break, and just go into the player's inventory. Unlike the method that does damage to enchanted items with "On Use" effects and such, which does specify that the item should be removed from the inventory once it breaks.

From FormulaHelper.cs:

Code: Select all

/// <summary>
        /// Applies condition damage to an item based on physical hit damage.
        /// </summary>
        public static void ApplyConditionDamageThroughPhysicalHit(DaggerfallUnityItem item, DaggerfallEntity owner, int damage)
        {
            Func<DaggerfallUnityItem, DaggerfallEntity, int, bool> del;
            if (TryGetOverride("ApplyConditionDamageThroughPhysicalHit", out del))
                if (del(item, owner, damage))
                    return; // Only return if override returns true

            int amount = (10 * damage + 50) / 100;
            if ((amount == 0) && Dice100.SuccessRoll(20))
                amount = 1;

            item.LowerCondition(amount, owner);
        }

I did this in my mod for the desired effect, if that would be useful:

Code: Select all

if (1 == 1) // Only runs if "Fading Enchanted Items" module is active.
                {
                    if (item.IsEnchanted) // If the Weapon or Armor piece is enchanted, when broken it will be Destroyed from the player inventory.
                        item.LowerCondition(amount, owner, playerItems);
                    else
                        item.LowerCondition(amount, owner);
                }
                else
                    item.LowerCondition(amount, owner);

User avatar
Interkarma
Posts: 5686
Joined: Sun Mar 22, 2015 1:51 am

Re: [0.10.25] Enchanted Weapons And Armor Broken From Combat Break But Don't Disappear

Post by Interkarma » Sat Jul 25, 2020 10:46 pm

Thanks for report, will tag this for review.

Post Reply