Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the standard practice for dealing with attribute modifiers in games where units have attributes, such as RTSs, MOBAs and RPGs? Specifically, in which order are "buffs" given to the unit?

Suppose the case where unit X has 10 blah-points (BP). It obtains two modifiers that add +10% blah-points, and another one that adds 30 blah-points. Finally, a enemy unit applies a -40% blah-points modifier. What is the usual way of processing this, for player familiarity's sake?

Aggregate by grouped type

(10+30)*(1.0+0.1-0.4) = 28

Obtention order

(10*(1.1)+30)*(0.6) = 24.6

Aggregate iteratively by type

(10+30)*1.1*0.6 = 26.4

Some other way?

share|improve this question
You forgot non-compounding, i.e. all percentage modifiers are applied to a base stat level. That is, two +10% and a +2 buffs will yield a +20% and +2 buff. – congusbongus May 12 '14 at 6:32
possible duplicate of What's a way to implement a flexible buff/debuff system? – Laurent Couvidou May 12 '14 at 8:08
And another one there:…. – Laurent Couvidou May 12 '14 at 8:09
@LaurentCouvidou Not a duplicate, Im asking for the theory, not implementation. – Kroltan May 12 '14 at 13:29
up vote 2 down vote accepted

It's really up to you how you implement these modifiers and it heavily depends on your game, the type of stats and items you have. Aggregating by grouped type is probably the safest option, because values won't spike as fast as with an iterative approach. A calculation based on the order when you obtained a buff is probably a bad idea, because the user might get different stats with the same buffs (obtained in different order) and wonder why that's the case.

As far as I know, popular games like Diablo 2 aggregate by grouped type. Pretty much what you did in your first example.

However there are some things to consider:

  • Armor and Weapon pieces usually have separate percentage-based calculations (eg. +60% damage on the weapon will be calculated for the weapon only (fixed-damage * 1.6) whereas +% damage modifiers on the armor will come into the calculation later. So basically the weapon(s) get evaluated first, resulting in the "base-damage" for the total damage calculation from skills, buffs and armor stats.
  • An enemy could have a -40% physical damage modifier, which will only be evaluated once you hit that enemy. You'll deal total-damage * 0.6 damage to the enemy. Enemy effects on you (eg. a curse or a buff vs. an enemy type) will be factored into your base stat calculation.

There's a pretty detailed list of how calculations work in Diablo 2 on the Arreat Summit website (scroll to "Character Attributes"). This might be a good starting-point for your own formulas.

share|improve this answer
Thanks! It makes sense to have the base stat calculated first, then apply the extra buffs. Also, great link! – Kroltan May 12 '14 at 9:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.