How to upgrade weapon damage amount in UCC/UIS?

Sangemdoko

Moderator
Staff member
This is a frequently asked question so I'll try to answer it here in some detail.

There are two ways you can upgrade a weapon in general.
1. Swap the current weapon by another weapon with better attributes.
2. Change the item attributes of your current weapon.

Option 1 consists at creating multiple item definitions which inherit from one another. It is fairly straight forward as you simply need to remove the current item and replace it by the new one. Since the item definitions are predefined, no need for item attributes that change at runtime.

Option 2 requires a bit of code as you will want to change the item attribute value at runtime. The documentation give examples on how to get and set attribute values through code: https://opsive.com/support/documentation/ultimate-inventory-system/attributes/



In both cases you will want the script that deals the actual damage to get the value from the attribute instead of a constant value. To do so all you need is the ItemBinding component.
1600673277000.png

In the example above I Bind that DamageAmount Item attribute to the "DamageAmount" property on the "ShootableWeapon" component. I do so by setting the item category to a "Weapon With Impact" (a custom item category which has the DamageAmount attribute).

This way whenever I spawn the assault riffle I will bind the damage amount attribute to the property on the shootable weapon. changing the attribute value will automatically update the weapon damage amount. The other way is true too. Changing the shootable weapon damage property will update the attribute value.
 
Hi @Sangemdoko,

Thank you for your reactivity. I understand a little better.

I'll try the Item Definitions and Item Attributes method from the documentation.

I will see how to switch from one level to another using a script and option 2 that you gave above.
 
Top