Monday, September 3, 2012

Designing Attack Damage Formulas

I was doing some research into combat systems for a game I'm working on when I realized that game combat isn't about numbers; it's about feeling. The numbers are just a method for the game designer to deliver that feeling. So in that vein, I came up with some rules for combat systems.

  1. A weapon with twice the power should result in twice the damage being dealt.  (Avoid confusion)
  2. Numbers need to keep getting bigger. (It feels like progress)
  3. Damage reduction should come in 3 settings: low, medium, and high. Each one is a constant percentage throughout the game. (Yes, this conflicts with the previous point)
  4. The only purpose of critical hits is to add excitement to the random number generator. (The best rewards are unexpected)

Base Damage
The most surprising thing to me is that every game I looked at (with one exception) uses a very simple formula to calculate the damage dealt from a basic attack. I expected there to be something more complicated in more modern games but ultimately simple is all you need and, as we'll see later, all the complication is in the damage reduction formula.

BaseDamage = WeaponDamage + CharacterDamage + Random

Weapon damage is usually listed as is on the weapon (or some multiple of). The character component damage varies a bit, but it typically some combination of player level, strength, and class. The random component can come in the form of a multiplier or having weapon damage represent a range of values.

Damage reduction
Older games will do the simplest thing and just subtract the defense value from the base damage. However, this has some side effects. Weak weapons will do no damage and powerful weapons will be unstoppable.
The way around this problem is what modern games do: multiplicative defense. This allows weak weapons to still do some insignificant amount of damage while powerful weapons still lose some effectiveness.

Now, how does one calculate the reduction value? The simplest approach DEF/SomeNumber is good enough for monsters, where a designer can control it. This is what Chrono Trigger used. However, when it comes to player defense, using that formula leads to problems due to a concept called effective health. Effective health is a model that virtually increases players health instead of reducing damage.

EffectiveHealth = PlayerHealth/DamageMultiplier

While effective health isn't a good system for using in-game, it provides a useful measuring stick for designers. It a good measure for the feel of a given armor reduction and shows off the issues with ever increasing damage reduction. When the damage multiplier is close to 0 (from perfect armor) it reduces the incoming damage to zero which makes the effective health infinite because the player can't die.

Solving this requires two things: diminishing returns to damage reduction from additional armor, and an ever increasing requirement for armor as players level. The first makes it so that the damage reduction never can equal 100%. Then second creates demand for better and better armor. The first on its own isn't good enough because it will cause the best armor in the game to be not much better than the armor somewhere from the middle. Depending on the difficulty of obtaining it it may not be worth it to the player to go for the upgrade. The second criteria will require ever increasing armor just to maintain a fixed damage reduction. Sure, this makes the game a bit of a treadmill, but we're talking about a game where a number is the only differentiating factor between two items. Any game that has one item that is superior to a second item in every possible way is all ready short on gameplay ideas. If you're making a treadmill, might as well make it a good one.

The simplest and most effective diminishing returns formula I've come across is from Diablo II.

f(x) = (x*c)/(x+c)

As x gets larger and larger the result approaches, but never achieves, c which is the cap. Because, for damage reduction, we need a percentage the formula is typically simplified to:

f(x) = x/(x+c)

Where the result approaches but can never achieve 100%
For our case of damage reduction, we want x to get bigger throughout the game (rule 2), but we want the result to stay the same (rule 3). To get there we need to make c get bigger and bigger as the game goes on. To reduce the amount of work the item/monster designer has to do, games, such as World of Warcraft, use a multiple of the attackers level for the value of c.

Critical Hits
Critical hits are the easiest to design because they only exists to spice things up. They were originally designed to emulate some sort of combat realism, but games that try to emulate realism aren't games; they're simulations. With that in mind, the basic formula of crits doing double damage works great in almost every situation. Some games use damage and a half because crits can cut both ways and nobody likes a surprise death. If you want to turn crits into a tactic against high defense opponents then make the bonus damage ignore armor. Also don't forget that crits don't have to be called "critical hits" to add excitement. They can be called "extra swings" or "chance on hit". There's no need to just have one kind; multiple bonus damage events happening simultaneously is what legends are made of.