how to use defense atribute
how do i make armor increase defense and decrease damage taken when attacked in blueprints
asked Jun 08 '17 at 06:45 AM in Blueprint Scripting
There is no fixed way to do that. There is no function to call or node to use. It comes down to how you define the damage formula.
A very easy example is: DamageTaken = clamp(Damage - Armor, 0, 9999999999) Only damage that exceeds your Armor value will be taken in this case. You can also modify it to be only a partial reduction in damage by doing something like: DamageTaken = Damage * (1-Armor/MaxArmor) In this example the damage taken is reduced based on the % of your MaxArmor value you have.
You design how damage is taken and you have to incorporate the Armor variable in that calculation somehow.
answered Jun 08 '17 at 07:01 AM
It depends on many factors like the range of damage and armor in your game, your game genre, different types of damages (like spells, melee,...) and your defending system in total (your game logic). I suggest the following function. It's an acceptable function for a mid range game which doesn't need to have a complex defending system.
ReceivedDamage = (1 - Armor/(C + Armor))*Damage. Where C is a constant.
Received Damage = (1 - Armor*W/(C+Armor*W))*Damage. Where C and W are constants. (Advanced)
If I remember correctly, the second formula is the one which is used in Warcraft. Note that the constants are in fact functions of the damage type. For instance a 100 spell damage is not supposed to deal the same damage to a pawn as a 100 piercing damage does. As I said it's a mid range game formula. If you have more complex battle system, then you might need to have several formulas for different circumstances.
Follow this question
Once you sign in you will be able to subscribe for any updates here