Attribute and Formula Help

Started by
7 comments, last by ferrous 9 years, 10 months ago

Hello.

I’m currently working on a game and I need to develop a set of unit attributes and combat mechanics. I’ll be honest, this is my first foray into this aspect of game design and I’m feeling a bit lost. I wouldn’t mind getting a little advice or direction.

First, let me explain a bit about the unit attributes. My main focus is to have the attributes themselves be as simple as possible while keeping the number of overall attributes to a minimum. Currently, I have 5 unit attributes (not including HP):

Strength (STR) A unit’s base attack / damage value
Defense (DEF) A unit’s base defensive value
Intelligence (INT) A unit’s ability to research equipment
Magic (Mg) A unit’s aptitude for magic (modifies attack and defense)
Tech (Tc) A unit’s aptitude for tech (modifies attack and defense)

I realize that this might make some of the mechanics difficult to develop and that I may need to add or change a few attributes. This is just my ideal for now. A few notes about the attributes though.

- All units have standardised movement. Having a movement attribute is not needed.

- Both units must be at the same location in order to attack one another. Having an attribute for range is not needed

- The game is turn based. Having an attribute for speed is not needed.

- Values for STR, DEF, INT will range from 10-99

- Values for Mg and Tc will range from 0-10

My biggest problem is that I’m not experienced enough yet to know where to start coming up with effective formulas for combat. All of my attempts so far have resulted in awful exponential increases or they only work for that specific unit (not what I’m going for).

Damage
What I’m trying to develop is a formula where STR is used to determine the base amount of damage a unit inflicts when attacking. I’m also trying to incorporate Mg and Tc into the formula as modifiers. If a unit possesses an affinity for Mg, then that unit’s total amount of inflicted damage will be increased – to what extent is determined by the Mg value. In this case, the units inflicted damage is no longer counted as regular damage, but as Mg damage. If the unit instead possessed a value for Tc affinity, the damage would then be counted as Tc damage. If the unit possessed values for both Mg and Tc, the damage would be counted as Mg / Tc.

Defence
Similar to Damage, what I’m trying to develop is a formula where DEF is used to determine the base defense of a unit when being attacked. Again, I’m also trying to incorporate Mg and Tc into the formula as modifiers. If a unit possesses an affinity for Mg, then that unit develops a resistance to Mg damage – to what extent is determined by the Mg value. The same goes for Tc resistance if a unit possesses a Tc affinity.

Critical Hits
Very basic. For now I’ve simply set it as a 20% chance for a critical per hit with 1.5x damage being dealt.

If anyone has any feedback on my proposed attributes or on where / how I can get started on building some of these formulas, I would be most appreciative.

Cheers,

Drahaus

Advertisement

You need to decide how the combat rules should behave, then formulas that fit the requirements will be easy to find.

For example, consider critical hits:

  • Why do you want higher damage variance? How is low variance bad? Barring strange effects, higher variance gives a chance to the weaker party, and every game needs to find the proper balance between confidence and uneasiness (for strong characters) and between despair and gambling (for weak characters).
  • Wouldn't rolling virtual dice for damage, with the possibility of choosing the probability distribution of damage output quite freely for a desired expected value (in particular, larger variance can be obtained by summing fewer larger dice), be more flexible than a mixture of "high" and "low" damage?
  • Are you OK with a bimodal distribution? Would the players notice?

Or consider special (magical) attack and defense:

  • Against a given reference opponent (e.g. Str 50, Def 50, Mg 5), increasing Mg is equivalent to increasing Str and Def. What is the equivalence? Does it depend on your stat values? Or on the opponent's stat values?
  • For example, you might want a very linear system in which a +k Str or Def increase is always as useful as +1 Mg, regardless of your stat values, and against any enemy: expected magical attack damage could be (Str+k*Mg)/(Def+k*Mg).
  • Or you might want a strongly level-based system in which lower Mg values don't stand a chance against higher ones, with Str and Def mattering only in the same Mg tier: expected magical attack damage could be min( (Str-Def)*(attacker Mg - defender Mg), 0)
  • How many points of Str, Def, or Mg should equipment be worth? Should it vary according to stat values?

Omae Wa Mou Shindeiru

I think one key information missing is what range of damage you'd like to see (minimum to maximum).

From the above, I'd be tempted to treat magic and tech as "piercing" damage.

For example, when dealing magic dmg:

If MG > 0

(adding the magical damage imprint)

Damage = STR * (2 * (MG / 10))

Magic defense would then be:

Defense = DEF * (2 * (MG / 10))

*Parenthesis used only to clarify train of thought.

Note that magic damage would deal much less damage than a regular attack in most circumstances, but that defense would also be much lower, effectively making the damage go through more easily.

Example:

2 units, each with 50 STR and 30 DEF

Regular attack: 50 - 30 = 20 damage dealt

Let's assume it's a MG 6 attack vs a MG 6 defense

Damage = STR * (2 * (MG / 10))

50 * (2 * (6 / 10)) = 60

Defense = DEF * (2 * (MG / 10))

30 * (2 * (6 / 10)) = 36

60 - 36 = 24 damage. Thus, the same stats result in a larger amount of damage if magical because of factoring twice the modifier of magic (which is based on the difference between str and def).

Now, I'm going to assume that units with a better magic would actually be much less of a fighter and vice versa.

Let's assume a fight between these:

UNIT 1 - "Spell Caster"

STR - 30

DEF - 20

MG - 7

UNIT 2 - "Warrior"

STR - 70

DEF - 50

MG - 2

Unit 1 would deal this damage:

Damage = 30 * (2 * (7 / 10)) == 42

Defense = 50 * (2 * (2 / 10)) == 20

Damage dealt = 42 - 20 == 22

Unit 2 would deal this damage:

Damage = 70 * (2 * (2 / 10)) == 28

Defense = 20 * (2 * (7 / 10)) == 28

Damage dealt = 0

If unit 2 was allowed to make a non-magical attack:

Damage = 70

Defense = 20

Damage dealt = 70 - 20 == 50

How would life range? And how expendable are the units meant to be?


You need to decide how the combat rules should behave, then formulas that fit the requirements will be easy to find.

I believe that this is the right idea. You should have an idea of what you want the player(s) to experience when combat takes place and try and find formulas that create that result (at least as a starting point) keeping in mind that, assuming the game is player vs computer, at the end of the day you want the player to win.

You probably already have several types of units in mind and an idea of how they will do in various situations and how they should be used most effectively.

  • Without bonus modifiers, what should a player expect when unit A and unit B confront each other?
  • Should A quickly over power B taking little to no damage?
  • Or should A typically win after x rounds of combat taking a moderate amount of damage?
  • How many times without healing should a player expect to be able to use unit A to fight unit B's before unit A is destroyed?
  • What about with healing?
  • Answer all those questions again but this time unit A has maximum bonuses or special abilities.
  • Again but with unit B has maximum bonuses or special abilities.
  • How much experience in the game will the player have and how much advancement (if any) will unit A typically have before encountering unit C?
  • How should unit A do in combat against unit C before and after that advancement?

The advice given above is sound. If you'd like some additional reading I highly suggest checking out the following PDF by Whitson John Kirk III:

http://madbrewlabs.com/labs/wp-content/uploads/2008/08/rpg-design-patterns-9-26-05.pdf

It's invaluable for getting a big-picture idea on how your attributes/stats fit into the overall design. It is tailored to pen-and-paper RPGs, but the information is applicable.

Indie games are what indie movies were in the early 90s -- half-baked, poorly executed wastes of time that will quickly fall out of fashion. Now go make Minecraft with wizards and watch the dozen or so remakes of Reservior Dogs.


I think one key information missing is what range of damage you'd like to see (minimum to maximum).

The range of damage values is only a scaling factor, so simple to manage that I forgot it in the example formulas in my post.

The starting points are

  • A set of benchmarks: the fight of unit A vs. weaker unit B should end with A's victory with probability p, often p=1, and its duration of n turns should follow a distribution with a given mean N and a given minimum and maximum, possibly approximate.
  • A range of hit point totals for different units: highly compressed like in Warhammer to make defense and "saving" hit points a big deal, extremely wide like in D&D to make minor damage insignificant, or something in the middle.

Given these constraints, it's obvious that, if unit B has b hit points, A's typical attack should do b/N average damage per turn, independently of how the stats and equipment of A and B determine damage.

Different ways to do b/N damage per turn are also independent from stats:

  • Fixed and certain damage X every turn: X=b/N. Only an option if hit point ranges are large or N is very small, or the necessary rounding to an integer will distort damage values.
  • Random damage: unit A's damage can be a random variable with an average of b/N. Winning probability p and the distribution of fight duration n can be computed from the distribution of damage.
  • A chance to miss: if unit A hits with probability q, doing X damage, q*X=b/N. Critical hits are a slight generalization to X or Y damage rather than X or nothing: q*X+(1-q)*Y=b/N. With both misses (probability 1-q) and critical hits (probability c conditional on hitting) you simply add three branches for X,Y and 0 damage: q*(c*X+(1-c)*Y) =b/N. And so on; X and Y can, of course, be random variables.
  • Random delay: if unit A attacks (on average) every m turns doing X damage each time, X/m=b/N. In most games X<b (no 1-hit kills) implying m<N.

Omae Wa Mou Shindeiru


The range of damage values is only a scaling factor, so simple to manage that I forgot it in the example formulas in my post.
The starting points are
A set of benchmarks: the fight of unit A vs. weaker unit B should end with A's victory with probability p, often p=1, and its duration of n turns should follow a distribution with a given mean N and a given minimum and maximum, possibly approximate.

I partly agree. Your model is sound, especially when confronting two units vs one another, but when falling into the bigger gist of things (factoring multiple units), you end up short of delivering a model that can consistently determine how each unit interacts with one and the other without proper scaling.

Case in point, a modern RTS (Starcraft 2) and it's economy of damage and how marines compare to zerglings and zealots at the same time, and how an upgrade shifts this balance. They've used the smallest possible integer values to make everything work, which would've been an impossible estimate if thought the other way around.

Well, you should start on a very abstract level, which is the condition of a unit: eg 0% = dead, 100% full health, therefor

hp = [0...100]

Now you need to consider how damage is applied, try to make it as simple as possible, eg

hp_new = max(0,hp - dmg)

Now, how does defense make sense ? It should reduce the dmg linear (eg dmg' =dmg-def) or it could reduce it percentally (dmg' = dmg * 1/def) or you could scale your hp like this

hp_combat = hp * (100% + def%)

hp_combat_new = max(0,hp_combat -dmg)

hp_new = hp_combat / (100% + def%)

You can put this into a single formula

hp_new = max(hp - dmg/(100%+def%) )

This way your def value of x increases your hp for a single strike for x%. I like it this way, because it is simple and you can scale dmg and def without fearing to hit some scaling pitfalls (eg. if you have a linear effect, what happens if def>dmg ? If you use a percentally effect, what happens if def approaches 100% ?) Thought the percentally formula is the same concecpt as hp scaling, hp scaling is simpler to design (Is a differenrence of 99.986% def and 99.973% def of late game content still readable ?).

Well, after this you can try to add some obfuscation and specialisation. Eg. add defense for special elements (eg fire), add some additional hp scaleing (thought it is the same as def, but has some other name) etc.

This may or may not help you, but being able to graph the curves for damage as certain values increase and visualize the curve you want might help. To that end, this is my favorite graph website:

https://www.desmos.com/calculator

This topic is closed to new replies.

Advertisement