Multiple damage types in one hit

Hello,

I have a question on how to pass multiple damage types in one call to ‘Target’->TakeDamge(…)

In TakeDamage I calculate if target should avoid the damage(ie. miss, dodge)

For example:

I have a sword that deals three types of damage: Physical, Lightning and Fire. [Path of exile like]

In a single attack character deals all three types of damage, so the target will either avoid all types of damage or take all types of damage.

For now I have 3 solutions:

  1. Call TakeDamage for each of the damage types → avoid chance will be calculated every damage type in a single attack, so I don’t want to use this.
  2. Move avoid calculation to the damage causer → if avoided, don’t call TakeDamage
  3. Overload TakeDamage for my specific purpose

I am leaning to the third solution, what is your take on this, have any better ideas/solutions?

Hey there, you can create your own DamageType that has an array of DamageTypes.

Thanks, I have one question to that, how would you pass damage amount for specific type(ie. two damage types, one deals 10dmg and the other 25dmg), since “DamageTypes are never instanced and should be treated as immutable data holders with static code functionality. They should never be stateful.”, and TakeDamage takes only one variable for damage amount.
My damage amounts are calculated during runtime from equipped items, ability level, buffs, debuffs etc., so I cannot just specify the damage in blueprints for each type and get static value.

I suggested that solution but i’m not sure if that is the right way of doing it, you could have a TMap of UDamageType and flot and for each type of damage you could associate a specific damage and then process everything in TakeDamage. As an alternative you can call TakeDamage multiple times for each type of damage like you mentioned and check the avoidance before the first call.