RPG/Moba code theory: Damage

Hi Folks,
Hoping to get some insight on what’s a better model for coding damage.

Presently, the player has various abilities (including BasicAttack) as instances of an Ability class. When these abilities are used, they create a DamageObject, which takes the attacker, their ability power, and the target(s).

It then goes and calls a DamageMe(this) on each target, passing itself along; the DamageMe() calculates final damage, applies it to the target, etc.

The idea here is that each target may adjust the damage done to it, based on armor, status effects, or whatever.

Is this a good model? Generally speaking, should the code that determines final damage be a function of the damage object (taking into account the attacker’s and defender’s abilities) or the player receiving damage (giving the opportunity to overload the DamageMe() function)?

Is using a DamageObject a good solution, or should I simply pass to the DamageMe() function the ability that’s causing the damage?

Just FYI, i’m working on a moba-style game where the abilities will do more damage over the time, and the players will be able to be under buff/debuff style effects.

Thanks for the input!

I basically do the same thing. It’s really a choice of responsibility, do you want the object to be responsible for damage? The attacker? The victim?

If the DamageObject is responsible it makes sense, but the victim no longer has custom control over niche cases that the DamageObject might not be aware of for some reason. It’s basically just assuming that things are going to be ‘right’ when it gets damaged.

Either way, I would just think about it for a while and then just try a path and start testing it out, not sitting on it too long.