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!