Damage Calculation


Another task of StatsManagerComponent is calculating received damage.

There is also TakeDamage function in interface I_CanBeAttacked, but it is meant to check whether hit was parried / blocked etc.
then it calls TakeDamage from this component to subtract stamina or health.

Function TakeDamage takes in 2 parameters, and it uses other stats like Armor / Block to calculate final damage.

  • Damage - damage value
  • IgnoreStamina - if true, damage will be subtracted from health, otherwise it will remove it from stamina.
    Why do we need it? It’s mostly used when character successfully blocks incoming hit, then we want to subtract stamina before health


StatsManagerComponent also tracks number of received hits / damage, which are summarized and gets reset after 4 seconds if owner didn’t receive any damage.

  • RecentlyReceivedDamage - all received damage, no matter if it was subtracted from health or stamina
  • RecentlyReceivedHitsCount - all received hits, not matter if stamina was ignored or not
  • RecentlyReceivedSuccessfulDamage - only damage subtracted from health
  • RecentlyReceivedSuccessfulHitsCount - only hits where stamina was ignored or there wasn’t enough stamina to absorb all damage

Those variables are mostly used to implement AI behavior, but could also be used to display recently received damage.
Example of that could be that AI can’t get stunned if RecentlyReceivedSuccessfulDamage exceeds 50 (BP_BaseAI -> CanGetStunned).