Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

I need help making a damage equation for my RPG

This topic is 5802 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making an RPG in VB. Don''t laugh. My problem is mathematical, not lingual. I need a good damage equation based on Attack and Defense. The maximum values for each are 100. I am going nuts trying to figure out a good equation. Any help is appreciated.

Share this post

Link to post
Share on other sites
i''m not exactly sure by what you mean by a damage equation, from what it sounds like you''re saying though you want to calculate the new life of a player after it has been attacked based on the defenses it has. if this is the case then this may work.

Defense = DefenseItem1 + DefenseItem2 + etc. this gives you the total defense you have.

Damage = value for weapon

newLife = life - (Damage - Defense)

Share this post

Link to post
Share on other sites
Maybe something like:

Damage = YourAttack / EnemysDefence + YourAttack / 10

This ensures that the enemy''s defence has a large impact on the damage, but a good attacker can''t be stopped cold.

Just an idea, do what you feel is best.

Share this post

Link to post
Share on other sites
These look like good ideas. I''ll need to test them, but they look good. For clarity I''ll define "damage equation". The equation should tell me how much HP to subtract from the defender based on the attacker''s attack and the defender''s defense. I hope this makes things clear. BTW equipment adds to the total attack/defense of a player. Your idea looks good gamechampionx. I''ll give it a try.

Share this post

Link to post
Share on other sites
If those other damage equations don't work well, you could try and Google the D&D rules. They probably have a very good damage system.

_______________ ___ ___ ____ ____ ____ ____
| | | | | | \ \ / / \ \ / /
| | | | | | \ \ / / \ \ / /
----- -----| | | | | \ \ / / \ \ / /
| | | | | | \ \ / / \ \ / /
| | | | | | \ V / \ V /
| | | | | | \ / \ /
| | | | | | / \ / | | | | | | / ^ \ / ^ | | | \__/ | / / \ \ / / \ | | \ / / / \ \ / / \ | | \ / / / \ \ / / \ --- ------- ---- ---- ---- ----

[edited by - tuxx on June 30, 2002 1:19:40 PM]

Share this post

Link to post
Share on other sites
abd = attackers base damage
ap = attackers +''s (include magic items/weapons etc +''s to damage - a long sword may have +10 to damage, a ring of power may have a +5 to damage)

dbd = defenders base defence
dp = defenders +''s (include armour/magic rings etc +''s to defence - plate mail may have + 15 to defence, magic ring of defence + 8 to defence)

the attacker has a base damage of 20, a long sword (+10) and a magic ring of hurting (+5)
the defender has a base defence of 8, magic armour of the gods (+15) and a cursed ring of defence (-5)

td = (abd + ap) - (dbd + dp)
(+20 +10 +5) - (+8 +15 -5)

td = 35 - 18
td = 17

u might as well throw some random element in there as well
td = random(td/2, td)

Share this post

Link to post
Share on other sites
Theres some documents by Ben Siron on the mathematics of console rpgs like Final Fantasy and Breath Of Fire. These can give you an idea of what to do. Though whats important is that you direct the numbers where you want them to go. For example,

Character = Strength, Vitality.
Equipment = Attack Power, Defense Power.

And, lets just say that with a 100/100 in STR and ATP, it should do the most damage possible, which is 999. Theres one important detail to decide here. Do we want damage cummulative or multiplicative? For example, does the 100/100 mean you do 200 raw or 10000 raw? In the first, you''d need an after multiplier of 5 to make near 999, the second needs a divisor of 10.

However, if you just want something simple, try this.

Raw = Actor.STR + Actor.ATP - Target.VIT - Target.DFP
Raw = Raw * Random(Raw - (Raw/16), Raw + (Raw/16))
Target.Life = Target.Life - Raw
IF Taget.Life <= 0, TARGET IS DEAD.

Play with the idea, add in elemental multipliers or weapon class modifiers, or whatever little thing you want to make your RPG stand out.

-> Will Bubel
-> Machine wash cold, tumble dry.

Share this post

Link to post
Share on other sites
Real RPGs attack damage specifiers are usually complicated. Overloading operators can really shine here and make clean looking code(I dunno what it''ll do for speed - but you shouldn''t be calculating damage multiple times per frame).

Only considering attack and defense - you could make things easy and use:

Damage = Attack - defense;
and check if damage is negative(if you use an unsigned it will wrap around to a huge positive number) or zero.

Of course if you do that, when you attack the same monster you''ll always do the same damage, and any attack becomes static. Most RPGs have a randomness to the attack damange.

First, every now and then a critcal hit comes up based on luck usually, and 2 or 3 times the damage is dealt on that hit.

Continuing, dexterity is sometimes used to determine the range of attack damage. The higher the dexterity, the higher chance you will actually do your max damage in battle.

So using dexterity and critical hit rate, you''d get an expression like so...

maxattack = attack - defense
Damage = Random( maxattack - (100 - dexterity), maxattack) //Make it a range between your max attack, and your max attack minus some number that is inversely affected by your dexterity

if( random(100) < luck) //if you hit a number less than the luck stat(a higher number means more luck)

damage = damage * 2; //(damage *= 2) this is a critical hit

Of course, after you calculate your normal damage, you can start crunching your elemental properties/weapon modifiers and what not.

Note: Generally RPGs use 999, or 999 to cap numbers. For stats there usually isn''t a cap - rather they just give a character a certain stat value at the character''s highest level.

Also, there is a difference between attack and Strength in RPGs. Generall Str will go towards your physical defense too. Attack is usually the end number when combining a characters strength and weapon power.

IF you are making this a complicated RPG, I also recommend using many number for attack and defense. You''d probably need more variables than you think.

Like what I said about strength and attack being two different things. And also the fact that attack is dependant on the weapon being held too. An actual attack number should be generated everytime there is a hit, not predetermined by the character''s stat(unelss he/she wont ever use another weapon).

"Ogun''s Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.

Share this post

Link to post
Share on other sites
How about this one. To hit an enemy:

clamp toHit to range (0-100)
attackvalue=random between (0-100)
if (attackvalue>toHit) do the damage the weapon has.

You might want to give an attackvalue of 0-5 = always miss and 95-100 is always hit.

Here''s something to make it more realistic: Don''t include the enemy''s armor in the defense stat. Base the defense purely on the enemies speed, skill and weapon (some weapons can be used for defense really well, like sword, while others, like spears, cannot).

After getting a hit: Say the enemies armour is between 0-100. the damage inflicted is weaponDamage*(enemyArmor/100). The higher/better the armor, the less damage inflicted. This is more realistic than adding the armor to defense. In reality armor stops you from getting wounded/killed. Armor does not stop you from getting hit (exeption: shield. DO add the shields armor value to enemyDefense).

Hope this helpes,

Sander Maréchal
[Lone Wolves Production][Articles][E-mail]

Share this post

Link to post
Share on other sites
Hm, guys - sorry - I consider most stuff said here so far to be pretty crappy. Frankly, would anyone of you want to play a "pen and paper" RPG with this type of rules? There is no need to
(a) use decimals and
(b) use a linear random number generator.

Lots of good games and rulesets do better with a lot of simplier rules based around dice, and they are well proven - the games must be so simple that you can easily check them out with pen and paper before programmning them in.

That said, I consider MOST of the RPG rulesets out there to be crap, at least from my experience of pen and paper RPG''s years ago. The leveling system often is total crap - be carefull not to make this mistake. My best shot here is DAOC where you CAN realistically fight an enemy only within a VERY narrow level range. My complain here is not that I loose when I choose an enemy too strong (lets say one for lvl 12 when I am lvl 10) but that the system is SO unbalanced that (a) I die with one of two hits and (b) I will NOT hit him and IF I hit iim seldomly not make any significant damage. Means, not even 3 Lvl 10 players can take out the enemy for lvl 12.

Check out the Alternity Warship rules for some nifty ideas. They had, which I like as an idea:
(a) armor value defined by dice and random factors. The old story: you roll fo a hit, then the damage is substracted by the armor value, just that the armor value is random for every hit. That brings in the point that armor is sort of random - do you hit straight on the shileding or do you somehow slide through some sort of binding element. This way a lot of luck (great damage with a dagger) can still do SOME small damage to a knight (who is very unlucky determining the armor rating for this hit), though statistically there is no damage.
(b) they had - but this is for spaceships - different fire strength and resistance levels. When you ship is too small for the weapon hitting it, the damage is upgraded to critical damage etc. I forst did not like it, then I realised what it is for: to keep the numbers lower :-) So big battleships dont run into hundreds of thousands of hitoooints and need hundred dice for the damage. A battleship weapon normally is way stronger than a normal small cruiser, and it''s weapons are designed with batttleships as targets, so all damage to the small cruiser gets "upgraded". They also had different damage types (like wound, critical etc.) and the damage would be upgraded - the wound roll would suddenly be critical :-) Was a nice move.

In general, my main advice is:
(a) get some money
(b) go out and buy roleplaying books.

Avoid the typical mistakes done by most computer designers. For example morrowind has one:
- it is skill based and successfull use based. Means: hit with a sword and you gain skill points. Have enough skill points, you to hit value goes up.
Problem: The higher your skill the more often you hit. As a result, you gain skill levels iwith a sowrd FASTER when you are better. Sure you need more hits (tehy tried to balance this), but they failed - you accelerate your skill gains later on simply due to (a) tougher monsters = longer battles = more successfull hits and (b) higher skill = more hits for the same number of attempts.

SAD :-) I pretend they would NOT have had this if they would have a system they can plan and play and balance on paper first.


Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!