Sign in to follow this  
amaro57

Formulas

Recommended Posts

I've been a user of the RPG Maker for some time a while back, as such, I've moved onto other pre-made engines (I'm an artist) for games. As a result, I'm relatively new to the whole non equation-evasion party. I'd thought I'd share some of my current formulas I've come up with, I'd greatly appreciate any feedback or where I can improve them. Feel free to use these if you want.

Melee Damage = ((Strength x 2-5) + Weapon Attack + Buffs) - (Melee Defense x 2)
Range Damage = ((Dexterity x 1-3) + Weapon Attack + Buffs + (Concentration x .5-1)) - (Range Defense x 2)
Spell Damage = ((Intelligence x 2-5) + Weapon Attack + Buffs) - (Spell Defense x 2)

Melee Defense = (Guard ? Action Value) + Equipment Melee Defense + Buffs
Range Defense = (Guard ? Action Value) + Equipment Range Defense + Buffs
Spell Defense = (Guard ? Action Value) + Equipment Spell Defense + Buffs

Melee Counter = ((Guard x.5) ? Action Value) + Buffs
Range Counter = ((Guard x .5) ? Action Value) + Buffs
Spell Counter + ((Guard x .5) ? Action Value) + Buffs

Melee, Range, and Spell Damage have a randomized selection of the value multiplied by. The lowest will always be 0.5 (Concentration), 1.0 (Dexterity), and 2.0 (Strength and Intelligence). Values in between the ranges are determined by the tenth decimal place only. So if the range were 2-3, the values would be 2.0, 2.1, 2.2, 2.3, up to 3.0.

For Strength and Intelligence, the range of 2-3 would be chosen if the attack was un-effective or weak against the enemy, 3-4 If normal, and 4-5 if critical. The numbers between 3-4 are the normal range, each value between has a chance of being chosen (3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9). The range of 2-3 will never be chosen unless an attack is un-effective and then, each value will also have a chance of being chosen (2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9). The range of 4-5 (4.0,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5.0) has a 5% chance of being chosen, only if the normal range of 3-4 is applied to the enemy, and not the weak range of 2-3.

For Dexterity, 1-1.5 is the weak range, 1.5-2.5 is the normal, and 2.5-3.0 is the critical. For Concentration, there are no weak values, only .5-.8 for normal, and .8-1.0 for critical.

If Strength or Intelligence is multiplied by 4.0-5.0, it is considered a "Critical" attack. Only if Dexterity is multiplied by 2.5-3 and Concentration by .8-1, it is considered a "Critical" attack. Items or skills will have the effect to possibly increase the selection of the range of 4-5, 2.5-3, and .8-1.

Buffs vary from item effects to skill effects. They may affect the formula values (a=b*+c*) or the final outcome (a*=b+c).

Weapon attack is only calculated if the equipped item(s) have the stat according to the damage type being calculated. For instance, a sword may have only melee attack, spell attack, or range attack, both of two, or all three.

Action values depend on the state the character is in. For example, if the player is in mid-jump while hit with a lightning attack, the Action Value would be divide by 2. If the player was in a block stance, the Action Value would be multiply by 2. If the player was in a advanced counter stance, the Action Value would be add 20, and so on.
[b]
[/b]The "?" in the formula refer to the Action Values. Action States determine the action value the the operation of math used.

[b]Scenarios:[/b]

So let's take for example: The player is battling against a monster, the monster is not resilient to the player's weapon or method of attack. The player has a strength value of 20. The player is equipped with a sword that has a Melee Attack of 60. The player also has a skill to increase the rate of critical attack by 50%. The engine randomizes and decides the 50 for the critical range is chosen, and then the number of 4.5 is chosen. The enemy has a melee defense value of 50 . No buffs are used by the player.

Melee Damage to the Monster = ((20 x 4.5) + 50) - (50 x 2) = 50 Damage to the Monster.

So let's take for example: The player is battling against a monster. The player is not resilient to the monsters method of attack or weapon. The player has a guard value of 20. The player is equipped with armor that has a spell defense value of 30. The player's stance is a blocking stance which renders the player immobile but provides an operation of addition and an Action Value of 20. The Monster has a intelligence of 50, no weapons, and a buff that increases the final damage value by 50. The system randomizes and decides the 95 for the normal spell damage is chosen, and then the number 2.5 is chosen.

Spell Defense of Player = (20 + 20) + 30

Spell Damage to Player = ((50 x 2.5) + 0) - (70 x 2) = -15 --> -15 + 50 = 35

[b]EDIT: Modified after input from a fellow member from another forum, DarkYoshi.[/b]

Jump Distance = Base Jump Time * Room Gravity

Base Jump Gravity is a negative value. The duration of the Jump Key is the number of frames the key was held. It's calculated as follows:

Base Jump Gravity = (Jump Time / Jump Time Max)

Where jumpTime increases by 1 for every frame the jump key is held and jumpTimeMax is the maximum number of frames allowed to be held.

So using this equation, let's say the the Base Jump Gravity is calculated to be .5, while the room gravity is 20. So the player, after reaching the number of frames the key is held down, would be pulled back by gravity of the following calculated.

The Base Jump Height would just be a set number of tiles or pixels, each room would have a gravity value that affects the number of the max jump height. It would be calculated as such:

Jump Height = (Base Jump Height * Base Jump Time) ? Room Buff

Share this post


Link to post
Share on other sites
I am aiming for a more smooth combat flow and not a grindy game as enemies are not that abundant. So would you suggest then removing the subtraction and replacing it with which operation, or something completely different?

Also, I suppose I see what you mean about the high variation. I've decided to just opt the values and go on integer bases. Thank you.

Share this post


Link to post
Share on other sites
It depends on the power growth and combat mechanics you want to have. If the power growth is slow, you can get away with a Damage - Defense formula because Defense will never grow so fast that Damage is much lower. It's situations like this that breaks it :
Level 10 : Damage 20, Defense 10
Level 15 : Damage 30, Defense 15
Boss : Damage 30, Defense 15

Level 10 vs Boss = 5 Damage vs 20 Damage
Level 15 vs Boss = 15 Damage vs 15 Damage

The effective damage tripled between level 10 and 15. It makes it very hard to tune the battle difficulty because a few levels over and under the target level makes it impossible or too easy.

The other thing is to create tactical decisions, you almost need a - somewhere in the equation. If you want a "multiple low damage hits" vs "single strong hit" feature, you need to have subtractive defense else, one attack type stays more powerful because it affects both attacks proportionally. In this case, you need to tread carefully or the above scenario will haunt you. Play Sands of Destruction on the DS to see a combat system breaking down because of that poorly managed minus sign. They give you the choice between many weak attacks or few powerful attacks, but beyond the first hour, all you do is spamming these weak attacks because damage output is an order of magnitude higher.

If you don't need these things and build combat depth from another source(ex: added effects), you could get away with multiplications only. This is the easiest to balance because the only important number is character DPS. Final DPS is directly proportional to character DPS, so if a character is supposed to deal twice the damage of another, then as long as his DPS is twice that of the other guy, the gameplay will remain balanced. Ex : Damage = Damage * Defense%. However, this isn't without a downside. Depending on the implementation, it can lead to similar problems than above. For example, if I remember correctly, FF7 used Defense% = Defense/512. This means early game, armor barely has an impact and end game, each point of defense is more effective than the last. The defense point that makes you go from 0% to 1% would reduce incoming DPS by 1% while the one that makes you go from 49% to 50% reduces it by 2%. Warcraft 3 and WoW used a similar system(last time I checked), where each point of armor would increase effective life linearly. If 100 point of armor gave you 50% absorb, 200 would give you 75% and 300, 87.5%. It makes each point of armor equally important in defense.

There are a lot of ways to do it, it depends on your requirements. For example, in Novus Dawn, we wanted to have a scalable system(multiply everything by 10 and it should remain the same game) and that stats were roughly equivalent in strength, so we went for Damage = Attack / Defense * SkillDamage. Then we added an exponent on the Attack/Defense to curb extremes : Damage = (Attack / Defense)^0.7 * SkillDamage. Thus, if some character had twice the Attack, it wouldn't do 200% damage, but 162%. Similar thing happens when Attack is low. It keeps values in a tighter range in case the player figures a way to end up with 4 times the expected stat values, either by grinding or exploiting game mechanics. The downside to this is we need to use higher level mechanics to provide combat depth, like MP management or positioning for combo attacks.

So, first thing would be to plan out combat mechanics. Figure out which choices you want to give to the player. Then tailor the combat formulas around these choices. You may find that you have to drop something else because it's incompatible, but that means the game won't break down down the road because of it.

Share this post


Link to post
Share on other sites
[color=#1C2837][size=2]The best games imho often just use a similar equation to yours but provide monsters with varying defense and health such that repeated weaker defense monsters with high health go down to repeated small attacks faster (which should have a higher dps) but high armor lower health monsters go down to more powerful attacks quicker since their armor makes successive rapid attacks much less potent.[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]Note you can also partially normalize your damage if you want; it makes the balancing easier but I'd recommend against it if you can do without:[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]((Strength x 2-5) + Weapon Attack + Buffs)[b] * ((Melee Defense/2)/MAX_DEFENSE) - (MeleeDefense/2) + 1 [/b][/size][/color]
[size="2"][color="#1c2837"][b]
[/b][/color][/size]
[color=#1C2837][size=2]The +1 is for a minimum damage per hit and a small buff for rapid attacks.[/size][/color]
[size="2"][color="#1c2837"][/color][/size]
[size="2"][color="#1c2837"][/color][/size]
[color=#1C2837][size=2][/size][/color]
[size="2"][color="#1c2837"]
[/color][/size]

Share this post


Link to post
Share on other sites
[quote name='Forthright' timestamp='1308260822' post='4824244']
[color="#1C2837"][size="2"]The best games imho often just use a similar equation to yours but provide monsters with varying defense and health such that repeated weaker defense monsters with high health go down to repeated small attacks faster (which should have a higher dps) but high armor lower health monsters go down to more powerful attacks quicker since their armor makes successive rapid attacks much less potent.[/size][/color]
[color="#1C2837"] [/color]
[color="#1C2837"][size="2"][b]Note you can also partially normalize your damage if you want; it makes the balancing easier but I'd recommend against it if you can do without[/b]:[/size][/color]
[color="#1C2837"] [/color]
[color="#1C2837"][size="2"]((Strength x 2-5) + Weapon Attack + Buffs)[b] * ((Melee Defense/2)/MAX_DEFENSE) - (MeleeDefense/2) + 1 [/b][/size][/color]
[size="2"][color="#1c2837"][b]
[/b][/color][/size]
[color="#1C2837"][size="2"]The +1 is for a minimum damage per hit and a small buff for rapid attacks.[/size][/color]
[size="2"] [/size]
[/quote]

Sorry, what do you mean by partially normalizing my damage?

Thank you very much for your input, Tiblanc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this