# Combat System - Class Objects as Package and Listener

So I've been trying to map out a combat system and I have an idea I'm laying out that I'm looking for a sanity check on, as well as suggestions.

The idea is that all things that can do damage (weapons, spells, environmental traps, monsters that deal damage sans weapon) will have a CombatTalker() object attached that will contain information about the amount of damage and damage types (fire, frost, physical, magical, etc.), modifiers that it might have, and any special effects (apply DoT, blind, slow, etc.).

Everything that can take damage will have a CombatListener() object that takes that information and transmogrifies it with the receivers resistances and any special properties it may have.

The CombatTalker() will create a CombatPackage() from a collection class any time there is a collision, and send it to the CombatListener() on the collided objects, supposing it has one. The CombatPackage() is basically the raw data about the damage and effects. The CombatTalker() is a wrapper of sorts that generates the CombatPackage() based on the weapon (or whatever) base damage, then the specific details of that individual weapon, and sends it (like a network packet) to the CombatListener(). The CombatListener() unwraps the package, and in reverse applies the resistances then applies any relevant damage and effects.

I know some of that was slightly repetitive, but I was trying to outline the idea completely, which apparently took two paragraphs.

I know this might be slightly complex, but the creatures and players and weapons and spells can change over time, so there isn't just a pool of static data that can be attached to the item. It needs to be able to read stats from JSON, apply specific information about the damage and send it. The same goes on the other side in reverse.

Is there a reason that this is "too complex"? Am I considerably overthinking it, or is this a reasonable method for a combat system?

Thanks!

• I've used a very similar architecture in two separate projects I did in the past. I didn't regret it. I just used more pragmatic class names, like Combatant (things that can receive damage) and simply Damage for what you call CombatPackage. – Philipp Jun 16 '17 at 12:47
• I've changed the names to make a bit more sense over the past few months, but mostly the architecture is still how I noted above. I'm feeling much more comfortable with it as I see it work and have extended it a bit to allow for additional features. – Jesse Williams Jun 16 '17 at 15:49

This feels right to me. CombatTalker() ...generates combatPackage()...--> combatListener()-->Processed-->output values
But it would be more efficient to just send the values stored in CombatTalker() as parameters for combatListener() instead of generating CombatPackage() and then sending over to combatListener().
So your process becomes CombatTalker()--> combatListener()-->Processed-->output values