Health, Damage and Effects system - architecture advice

Hey all,

I am trying to implement a fairly simple system as stated in the title for health, damage and effects.

What I am trying to do is:

  1. object has health script that receives ‘take damage’ msg
  2. this forwards a msg to a status effects script of that obj for ‘calculate direct damage’
  3. the status effects script receives the msg and goes through its table of currently applied effects and calls for each of them a function like “CalcualateModifiedDamage”

On part 3 I get confused on how to implement it. How should I define these status effects and access their functions.

An example of what I what to achieve with this system is:

  1. A bullet hits a target.
  2. The bullet has dmg = 10, dmgType = “electric”.
  3. The target has status effects: Tired, Poisoned, Elite
    Tired: the target takes 10% more dmg
    Poisoned: the target takes 1 dmg every second for 3 seconds, if hit by poisoned dmg type, the dmg is increased by 5%
    Elite: the target takes 10% less dmg
  4. The target calculates the direct damage it will take (2.) by going trough all the effects (3.) and checking how they modify the dmg and finally substract it from the current health.
  5. Not sure if the calculation of bonuses should be additive or something else: +10% from tired +0% from poisoned because it is not poison type dmg - 10% because it is elite, so the direct dmg is unchanged -10

Do you guys have any suggestion how I should implement those status effects and access their effects in a clean structured way. Also, do you recommend any resources online that explain “good” practices for a system like that?

Here’s a good video on damage types (but for the Godot engine) https://www.youtube.com/watch?v=AStd632v7dY&t=495s. The idea is the same. You basically apply buffs as below 1 (i.e. you take .9 (90%) of damage) or debuffs (i.e. you take 1.1 (110%) of damage) and then multiply everything off the damage number.