Given the normal entity-component-system architecture, lets say we a component that give the entity Strength. Now on the game flow I want to give +4 strength do to the wielded weapon. What would be the best way to do this, considering that.

BaseValue => 10; Weapon => +4; Weaken Spell -2 (Temporary); CurrentFinalValue => 12

I could have many modifiers, positive or negative; I would like to know for a given entity attribute "Strength", what are the modifiers sum; I could add or remove modifiers and they should not remove from the base "Strength";

I could add as a component (StrengthModifierComponent) and apply the change to the StrengthComponent, then to be able to calculate the CurrentFinalValue, I would have to discover every component that affects "Strength" somehow and sum it with BaseValue. This might be easier if I have complete control of the system, but if I am building the system for general purpose this would have to be dynamic and there for complicated, making it possibly "slow".

I cannot put in the entity since the entity is usually just an identifier (int,Guid,SomeUniqueName).

I could make a ModifiableComponent which accept a list of Modifiers and would allow an easier interaction when making all the calculus. But wouldn't this break the ES architecture?

Thanks you.


2 Answers 2


Add the modifiers to the component that holds the value being modified. This means for the strength attribute, you'd add a list of strength modifiers to the component that defines the strength attribute. The modifiers are just data after all.

Then your systems will have no trouble accessing the modifiers because they'll already in the same component.

  • \$\begingroup\$ I was going towards this approach. Can you think how it could break? I do have an implementation without ES that works quite well. \$\endgroup\$
    – Oakcool
    Dec 2, 2013 at 22:19
  • 1
    \$\begingroup\$ The trouble areas I see are when you're applying modifiers. If you have an item that modifies attributes that are in multiple places (like a ring that adds +4 to damage of current weapon and +2 to character strength), it might be difficult to ensure that the modifiers get applied in all the right places. However, I think that can easily be solved with a nice messaging system. Just making sure you have a good solution to add/remove modifiers across multiple components. \$\endgroup\$
    – House
    Dec 2, 2013 at 22:25
  • \$\begingroup\$ U might be able to solve that by having the ring hold multiple modifiers that apply to different kinds of entities(tag component, type component?) \$\endgroup\$
    – Oakcool
    Dec 2, 2013 at 22:33
  • 1
    \$\begingroup\$ For sure. Each component should hold a list of the modifiers applied to it. Don't do anything like keeping the total, keep each modifier. You can make a modifier messaging system, that takes modifiers and broadcasts their specs, while each component listens for those messages and applies them to themselves. It's certainly something that can be worked around. \$\endgroup\$
    – House
    Dec 2, 2013 at 23:06

What you need are a component that sends out the damage dealt and one that receives the damage done, and applies any modifications to the damage before updating health.

The general workflow for an RPG type system can be modelled like so:


  • may have a "base damage", for example based on the wielded and used weapon
  • multiplies base damage with stats using custom formulas as desired
  • may have modifiers, such as "wears enchanted staff of quadruple damage"
  • sends a "packet" of damage information to the receiving entity(s)

Damage information contains attributes like the base damage, the "type" of damage (ie fire, magic, piercing, etc) and other attributes as needed.


  • analyzes damages for its type, may discard it entirely or just reduce it by a percentage (ie temporary protective force shield, immunity/resistances against magic, etc)
  • modifies incoming damage according to custom formula, goes through modifiers (ie arrow considers armor and perhaps dexterity while magic damage may consider intelligence and wearing a funny hat)
  • applies modified damage

Actual modifiers can be components too, but specific to the damage-doer and damage-taker components. I would give them different names (CombatModifiers), because there are other things besides resistances, shields, power-ups that can be relevant RPG modifiers during combat. Like an Ability to resist or be immune to certain spells (ie prevent boss monsters from being turned into a pet and subsequently not being able to kill it, unable to end the quest and reap the rewards).

So basically these are two components that send and receive information and process them accordingly. The above is only an example and depends on actual design requirements.

For example it may make sense to not calculate a total damage and leave it up to the damage-taker to generate the actual damage done. Based on the likelihood that the receiving end is going to modify the damage anyway, and may need to discard only certain components of the damage value such as discarding the +1 ice magic damage applied to the sword that just pierced through the armor and cut off a limb. Or vice versa. Also: random variation of damage, and critical hits, cause sometimes you're just lucky enough to hit the life-critical cheekbone arteria (I just made that up, but so is any damage in an RPG).

  • \$\begingroup\$ I like the idea here, but if you are doing Modifiers for anything, and by that I really mean anything. I could have a velocity modifier, that would apply to (X,Y,Z, Rotation) from the Velocity component. In this case I won't have the distinction of Doer/Taker, it could be a Spell that increases speed +1 for 30s, or any other property on the system, and by taking your approach, any time I add modifier I would have to go and make changes on the systems as well, to calculate it when acting on it. Ideally since its a data driven system, I should b able to add a new datarow and things should happen \$\endgroup\$
    – Oakcool
    Dec 2, 2013 at 22:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .