# RPG combat and gold/exp reward equations

I have a game that I'm creating, but I'm running across issues in keeping the ratios between high and low level players similar in the battle and reward equations. Obviously a higher level player should receive less experience, but have the upper-hand in battle when fighting lower level players and monsters. Here is how I'm calculating things currently:

Battle starts If player.dex > enemy.dex Accuracy = ((player.dex - enemy.dex)/2)*20

If player.dex < enemy.dex Accuracy = ((enemy.dex*player.dex)-enemy.dex)/player.dex

Accuracy is a percentage tested against a roll of a 100 sided die.

If accuracy > roll Hit success

If accuracy < roll Hit fails

If hit success All of the attacker's damaging items (spiked helms and shields, weapons, etc.) are added together and applied as such: Damage = (player.str + item.damage)-(enemy.dex + enemy.armor)

If the player is fighting a monster, I have a base amount of gold and experience which is modified according to the player: Gold gained = (enemy.gold*rand(1,10))/player.level Exp gained = (enemy.exp*rand(1,3))/player.level

If the player is fighting another player, then there will have to be a different equation for the rewards, but I'm not sure how to go about creating that one.

As this is my first attempt at creating (though I'm an avid RPGer), I'm not sure if there is kind of an "industry standard" form of calculating these things or not. I'm also afraid that these equations won't hold up once the player reaches higher levels (say level 50+).

• I can't upvote because of having just registered, but if I could I would upvote each of the answers. And I hesitate to accept just one of the answers because they each raise valid points and offer alternatives. Jul 28, 2012 at 17:19

There is no "industry standard" ( why do you think there are so many different systems? DnD/PF/d20, WoD, d6, GURPS, etc... ) when it comes to comparing two players and balancing the game.

@hustlerinc has a pretty good answer that focuses on the difference in player level, and handles it fairly between two people only taking into account their level.

I would revise your equations to something more like this:

Battle starts If player.dex > enemy.dex Accuracy = ((player.dex - enemy.dex)/2)*20

The equation itself looks alright, but you're doing extraneous math. (player.dex-enemy.dex)*10 gets you the same result. This now shows us the problem: If player.dex is ever 10 above enemy.dex, he will always hit. If your stats are reasonably bound ( something like 8-25 ), should keep more or less balanced. Additionally, what if they have equal stats? neither could ever hit the other.

If player.dex < enemy.dex Accuracy = ((enemy.dex*player.dex)-enemy.dex)/player.dex

This equation just looks terrible. Without knowing the range for stats, this equation makes absolutely no sense.

Accuracy is a percentage tested against a roll of a 100 sided die. If accuracy > roll Hit success If accuracy < roll Hit fails

Standard type stuff. I would actually suggest a different system. Start at 50% chance to hit. Use some sort of curved algorithm to determine the change in chance for one side or the other. For instance, 10v10 = 50%, 11v10 = 59%, 12v10 = 66%, 13v10 = 71%, etc. etc. For every point above the opponent, give them a bonus, but have it be decreasing return per point. Again, it depends on what your proposed ranges are.

If hit success All of the attacker's damaging items (spiked helms and shields, weapons, etc.) are added together and applied as such: Damage = (player.str + item.damage)-(enemy.dex + enemy.armor)

This could go extremely wrong. Suppose your player is using a ranged weapon ( which is usually based off of dex ), and the enemy is using a melee weapon ( based off of str ). This gives an inherent advantage to melee weapons, mechanically speaking.

If the player is fighting a monster, I have a base amount of gold and experience which is modified according to the player: Gold gained = (enemy.gold*rand(1,10))/player.level Exp gained = (enemy.exp*rand(1,3))/player.level

This I disagree with vehemently. Never divide by player level - you end up making a logarithmic ( reciprocal of x ) curve. Simple put, upon moving from level 1 to level 2, the character now gains half experience and half gold. From level 2 to level 3, he gains two-thirds of what he gained at level 2. Then 3/4, 4/5, 5/6, etc. The difference in gain from one level to the next approaches zero.

There are a couple of ways to deal with experience and gold. I find I tend towards the low multiplier method. Essentially, each level above 1, the amount of experience you need for the next level increases by a low multipler, something in the .125-.25 neighbourhood. However, this is cumulative. You end up with an equation for XP like such: baseXP * ( ( 1 + XPmod)^level )

• The fact that there isn't a standard is part of why this genre has persisted as long it has. It's something that is at least a little new. Jul 28, 2012 at 19:59
• How can I go about calculating ranged weapons? There'd have to be some sort of distance factor, wouldn't there? I don't use distance in any way in the game as of yet. Also, when you say 10v10, you mean level 10 vs level 10, correct? Jul 29, 2012 at 4:49
• @chaoskreator - 10v10 was for player.dex v enemy.dex, actually, but it could also be applied to levels - or any attribute, for that matter. As for distance... depending on what kind of ranged weapons you have, the short distance from player to enemy won't really matter in the grand scheme of things. ref: Diablo 2, for instance - the distance for a ranged weapon did not matter, because the relative screen distance was never more than 30 or 40 ft. Most ranged weapons are good out to 70 or 80ft before their 'damage' would start to drop (my physics is a bit weak, though)-I would ignore distance. Jul 29, 2012 at 7:08

First, I will tackle the problem of Accuracy, since it does actually have a correct solution in my opinion.

The problem with your equation for accuracy is that it depends on the difference between the dexterity, not the ratio between them. Here is what I suggest.

AccuracyInPercent = 100 * PlayerDexterity / (PlayerDexterity + OpponentDexterity)

If your random number, between 0 and 100, is less than the Accuracy, then it is a hit, otherwise it is a miss.

This means that no matter how powerful either person is, he will never get hits 100% of the time. It also means that a player with three times the dexterity of his opponent has a three times higher chance of winning.

Another advantage is that this will work with any range of stats.

As for the gold that will be rewarded, it could be related to the chance that the person wins the battle. There will be two constant numbers involved, A and B. B will be the baseline amount of gold won, while A+B will be the maximum amount of gold that could be won.

Gold = A * OpponentDext / (PlayerDext + OpponentDext) + B

This system means that a weak player beating a strong player will win more gold than vice-versa. This also means that no player will win too much gold from one battle.

One effect of the above equation is that a player with 200 dext will win as much gold by beating a 100 dext opponent as a 2 dext player beating a player with 1 dext opponent. To avoid/increase this, you could change A and B depending on the players involved.

• Just a note that you could calculate those A and B values programmatically rather than needing to give each enemy two values. For example, set a baseline gold value for A and set B to 2*A, or explicitly set B and set A to 0.5*B, or set a median value G and set A,B to 0.75*G,1.25*G, or whatever other scales you prefer. Jul 29, 2012 at 0:30

I would've done it like this:

Player level - enemy level = difference.

Then take the difference, multiply it by the amount you want to decrease reward for each level difference.

decreaseTotal = decrease (for example 0.05) * difference, this would give 0.15 if the difference is 3 levels.

Take the reward and multiply it by reward * (1 - decreaseTotal) and you have a percentage of total reward. In this case 85%.

This is the simplest of solutions.

• Would it just be reward*(1+decreaseTotal) if the opponent was a higher level? Jul 28, 2012 at 17:01
• If you do it right you don't have to, say the player is lvl 7, and the enemy is 8, that would return -1 as difference. -1 * 0.15 gives -0.15, 1 - -0.15 should give 1.15 (based on mathematical rules), without manually adding, but it depends how you setup your code. Jul 28, 2012 at 22:12