Damage doesn't seem to affect item condition

Discuss modding questions and implementation details.
Post Reply
l3lessed
Posts: 1400
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Damage doesn't seem to affect item condition

Post by l3lessed »

I was working on my compass mods trying to add the progressive damage feature. I want the glass only to break after a chest hit and to have less of a chance to break if wearing chest armor or clothing.

So, I setup the code to get the chest armor condition so I can check when it takes damage. However, it does not seem to register any changes to its condition int values, even when that body part is hit and I take damage. Am I missing how the condition system works? Do normal armor not degrade from being damaged?

Is there a simple way to get what body part the player was hit on last damage?

Here is the code:

Code: Select all

            //pump out current condition of chest armor to ensure it is getting damaged.
            Debug.Log(GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.ChestArmor).currentCondition);

            //check if chest armor is equipped and if so, check its condition against the last time it took damage.
            if (compassArmored && GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.ChestArmor).currentCondition != lastArmorHealth)
            {
                //update the last condition int value it had.
                lastArmorHealth = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.ChestArmor).currentCondition;
                //find the difference in condition int value to get total damage done to armor.
                float difference = lastArmorHealth - GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.ChestArmor).currentCondition;
                //pump out debug message for checking values.
                Debug.Log("ARMOR HIT: " + difference + " | " + GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.ChestArmor).currentCondition);
                //if the difference  is greater than 1 and the broken glass hasn't hit its last update texture, then update to next damage effect.
                if (difference > 1 && currentDamageTextureID != 4)
                {
                    currentDamageTextureID++;
                    if (currentDamageTextureID < damageEffectList.Count - 1)
                    {
                        damageEffectInstance.UpdateTexture(new Color(1, 1, 1, .9f), damageEffectList[currentDamageTextureID]);
                    }
                }
            }
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Damage doesn't seem to affect item condition

Post by Ralzar »

Magicono can probably answer this since he made a whole mod about getting armor/weapon damage to make sense :D

User avatar
numidium3rd
Posts: 187
Joined: Sun Mar 25, 2018 12:34 am
Location: United States

Re: Damage doesn't seem to affect item condition

Post by numidium3rd »

I would try setting a breakpoint for DamageEquipment in FormulaHelper.cs. Make sure ApplyConditionDamageThroughPhysicalHit is being called at line 1115 with the correct arguments.

l3lessed
Posts: 1400
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Damage doesn't seem to affect item condition

Post by l3lessed »

I rather not use a formulahelper override. This will then create conflicts with a number of other popular mods and also future mods that touch the formula helper.

I was hoping there was some way to pull this information without having to use a formula helper override. I guess I will use players health and have the armor affect how much or little health needs to be damaged before glass breakage.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Damage doesn't seem to affect item condition

Post by Ralzar »

Yeah, at the moment body part hits is pretty much impossible for the player to register anyway. We would need a mod to completely overhaul that before this even becomes something worth tracking. And when a mod like that is made, it can have mod messages that other mods can use to do their own effects.

l3lessed
Posts: 1400
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Damage doesn't seem to affect item condition

Post by l3lessed »

The thing that confuses me is there is code in the formula helper for damage to affect equipped items conditions value, but I don't see it reflected on the item when I monitor its condition value in the debug log.

Code: Select all

            damage = Mathf.Max(0, damage);

            Debug.Log("BODY PART: " + struckBodyPart);

            DamageEquipment(attacker, target, damage, weapon, struckBodyPart);
If this would damage the equipment like it seems it is suppose to, all I would have to do is monitor the specific equipment slot for a change in its condition value, and when it lowers in combination with the player health lowering, that tells us what body part was hit. But, this DamageEquipment routine doesn't seem to be applying to the chest armor I equip.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Damage doesn't seem to affect item condition

Post by Hazelnut »

It occurs to me reading this thread that players would be unable to tell when hit in chest and you could just have a random chance for it when player takes damage and the effect would be the same.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
numidium3rd
Posts: 187
Joined: Sun Mar 25, 2018 12:34 am
Location: United States

Re: Damage doesn't seem to affect item condition

Post by numidium3rd »

I may have figured out why you're not seeing a change in item condition in your logging. DamageEquipment calls ApplyConditionDamageThroughPhysicalHit which only lowers item condition by a nonzero value if it reaches a certain threshold.

At line 1130 of FormulaHelper.cs it calculates the condition amount to subtract like so:

Code: Select all

int amount = (10 * damage + 50) / 100;
So if the enemy does <5 damage to you in a given hit then your armor won't take any damage. I'd try testing with a higher level character so that harder hitting enemies spawn.

l3lessed
Posts: 1400
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Damage doesn't seem to affect item condition

Post by l3lessed »

Thanks for all the suggestions and ideas. It probably is a damage threshold issue, as I was not checking with higher damage enemies.

Either way, I think I found the best immersive system. The compass will have its own health, and every time the player takes health damage, so will the compass. However, what you're wearing affects this dramatically in a logical way.

Clothing and armor reductions stack, since they are layered clothing. Clothing reduction always gets calculated after armor reduction for an additional 15% reduction.

Nothing equipped on your chest, and compass takes full damage on chest hits.
Nothing but a clothing item equipped on chest, reduce the damage by 15%.
Leather Armor equipped on chest, reduction of 25%.
Chain Armor equipped on chest, reduction of 35%.
Metal armor equipped on chest, reduction of 45%.

With metal armor and clothing underneath, the compass will take about 55 to 60 percent less damage than the player took when their chest is hit.

Now I'm wrapping up cleaning up the last of the load errors causing issues when trying to use the mod across multiple saves. So many objects, enums, properties, and script instances to track, its taking time tracking them all down and ensuring proper load sequencing.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Post Reply