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

Locked
User avatar
Magicono43
Posts: 682
Joined: Tue Nov 06, 2018 7:06 am

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

Post by Magicono43 »

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: 6522
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 »

Thanks for report, will tag this for review.

User avatar
Interkarma
Posts: 6522
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 »

Thanks again for report. The suggested fix was a good one, I just added an additional check to ensure owner is actually player as this formula gets called against enemies too (e.g. for their striking weapon).

https://github.com/Interkarma/daggerfal ... d25ec196ef

Locked