   Fighting Equations
  I''ve been thinking of a way to do damage in a video game. My basic idea was for equations. You have four basic stats in the game: Attack, Magic, Defense, and Magical Defense. You have three different types of offensive techniques: Physical, Magical, and Both. When you have a Physical attack, the damage is:    Your Attack Stat - Your Opponent''s DefenseWhen you have a Magical attack, the damage is:    Your Magical Stat - Your Opponent''s Magical DefenseWhen you have a mixed attack, the damage is:    (Your Attack + Magical Stats) - (Your opponent''s Defense + Magical Defense)You''d have to do something to make it random. For instance, in a PPRPG, your attribute level would be the amount of twenty-sided die you would roll.For instance, if your attack was ten, and your opponent''s defense was nine, the damage would be:10d20 - 9d20Whacha think? 
  there are many diffrent ways to handle damage.You could have a contested role you role attack dice and defender roles defence dice. The more success you obtain vs the opponet the more damage delt.you could take attack-defense and have to role equal to or under that on a d(attack) do if your attack is 6 and defense is 2 then you''d have to role equal to or under 4 on a d6.You could have damage determined by d(attack) - d(defense)so if attack is 6 and defense is 2 damage would be d6-d2.you could get fancy and have damage =(attack-10+d20)*(defense/100)There are few things you have to determine first1)What are normal values of attack and defense?2)What is the average/maxium health in the game?For instance a damage system changes radicly if character can have between 100 and 10,000 life or if all characters have 10 health.   -----------------------------------------------------Writer, Programer, Cook, I''m a Jack of all TradesCurrent Design projectChaos Factor Design Document ;  I use a technique similar to yours in what I''m doing. However, I also have other types of damage included like fear and confusion (every attack has different stats to determine the potential to deliver a certain amount of each type of damage).But as Goth said, you have to be careful and balance out the average stats. This takes a lot of testing which is a good reason to keep your formulae simple.Peace Out! ;  Attack-Defense isn''t much of a damage formula actually, its pretty standard.However, lets talk about Randoms. Now that you''re in the computer world, you don''t have to restrain yourself to D20 mentality. A good random fuction would produce unpredictable numbers between 0.0 and 1.0 (or 0 and 4294967296), which you''d then perform some multiplication and or division to produce a fairly good "roll".Next, lets consider damage. In small numbers, a d20 roll would produce fights that are totally wacky.Attack:10  Defense:610-6 = 4, +d20 = 5<=x<=24.In a single hit, you''d either crush the enemy, or lightly tap him.Now, lets look at large numbers/Attack:2400  Defense:15002400-1500=900 +d20 = 901<=x<=920The little bit of extra randomness is a cute gesture here.What you may want to consider is taking the value after Attack-Defense and multipling that with some degree of linearity.  For example, 1.25 is a nice number.  4*1.25 = 5, 900*1.25=1125.So here, we''d want (1+(Rand()/4))*(Attack-Defense)That way a damage value of 4 or 5 makes an interesting fight, and a damage value of somewhere between 900 and 1125 keeps the fight in motion and not some blanket war of attrition. ;  I think that you should let the person decide what they want to hit with their hand of magic in a way.I would assume that it''s better to have it that when you hit physically you take a # off your opponent and when you hit with magic you take off a % off your opponent. Also that the less hit points you have the less power you have. So if your enemy had 10 hit points and you have 5 and you are going to attack him you will take around 5 points off them. You can have some luck to have the hit vary like -2 or +2 points and that the less hit points you have the more likely you will hit higher."Profanity is for those who lack intelligence and imagination to otherwise express them selves." "You are what you repeatedly do; Excellence, then, is not an act, but a habit." Aristotle  ;  I''ve actually been working on a battle system for an RPG my friends are creating.  I have it so that defense doesn''t actually decrease the damage done by attacks, it just increases the chance of an attack being blocked.  All you need to do with this set up is decide how you want Str / Wpn Pow to affect the "base" damage.  It really helps when creating formula to model these stats to have an extensive background in mathematics and a good knowledge of how functions behave and various ways to manipulate them to create exactly what you want.  For instance, I just created a function that models the accuracy of an attack based on the attacker''s speed, target''s speed, weapon accuracy, and the character''s proficiency with said weapon.  It took around 2 hours to finally nail down a good formula that behaves exactly as I wanted.  It is such that if the character''s speeds are equal and the character has zero experience with its weapon, then the accuracy is equal to the weapon''s accuracy.  As the speed ratio increases without bound, it goes to 100%, whereas when the ratio goes to zero, so too does the accuracy.  I also have it so that the character''s proficiency with the weapon slighly increases the accuracy based on the ratio of speeds such that it never causes the function to cross the asymptote at 100%.  It took a while, but I finally nailed it down .If you want to go with your system where defense actually decreases damage, you could try something like this:Damage = S*(W/(D+1))^1.5(S) = strength(W) = weapon power(D) = defenseIn this case you would have to have it scaled such that weapons'' power is, on the average, equal to the defense of the enemy at that point in the game.  The only problem with a formula like this is how it behaves at the extremes.  If the weapon you have has a really low power, you are going to do squat no matter what your strength is; if the enemy has really low defense (I added one to it so the game will never divide by zero ), then you are going to do a very large amount of damage.  I could probably come up with a better model if I took the time to think about it, but I have my own battle system to work on . ;  The previous project I was working on (well, playing around with, really) was a gamemaster program for a PnP role playing game.  In this project, the idea was that since the computer was handling the heavy lifting of math and memory, I could have the combat system as horrifically complicated as possible.  The goal was that an intuitive elegance would come out of all the numbers smashing away behind the screen, in the same way that you can get a feel for certain parts of combat in Everquest, even though you never see the numbers.A character would have a skill level in the armor they were using, a basic parry and dodge skill, and skills that applied to the weapon/combo/shield that they had equipped.  Every item had defense values (a leather cap might be 25 slashing, 15 piercing, 20 crushing) along with resistances (fire, cold, electricity, up to holy strikes, chaos and plasma) and skill modifiers (a light armor type would have a smaller dodge penalty.)  Weapons had parry speeds and modifiers, multiple damage types, attack rates/ranges/speeds.  All of these values modified each other, resulting in either a miss, a dodge, a parry, or an attack of X severity (compared to a damage type/critical table, which applied an Injury object to the character being struck)  Aside from this, any equipped object also had the ability to place effects on the wearer when struck, the attacker when struck, the target when striking, etc.  Amazingly, I actually finished that part of it.  It ended up being so horrifyingly complicated that it was unusable.When people were playing around with it, they didn’t care about the math, so long as what they saw made sense.  My advice?  Go with a basic attack level/defense level system, and move on to the next part of the game.;  Hi, Orionx.  Happy birthday again.Here''s what I did in my game:the attacker has a base strength (s), weapon power (p), and bonus strength (b).  all added together, this = damage (m)the defender has a base defense (d), armor defense (a), and bonus defense (o).  All added together, this = damage reduction (r)we will assign a random value (n) for additional damage which is a random number from 0 to m - r.Now, if you''ve got all the variables straight, here''s the main body of the attack:damage = m + n - r; if r < 1 then r = 1ORdamage = s + p + b + random(0-(m-r)) - (d + a + o)ORdamage = damage + a random number between 0 and (damage - damage reduction) - damage reduction.This works quite well in randomising battle, while keeping it under control.  Also, I have a similar system for magic and speed which randomises damage and chance of dodging respectively.  I hope I have helped you and not gotten you confused with my above examples with all those variables.   ____________________________________________________________official Necromancer of GameDev forums Game Writing section ;  My intelligence has dropped 4d20 just from reading this thread. It has dropped so low, in fact, that I''m writing this resonse. ;  Well, there''s a couple of things to think about here.First off, what weapons are each person using?  For example, if the attacker has an Axe, and the defender only has a dagger, then the attacker should get a pretty big bonus to his attack roll.  Moreover, when you have a system like this, you are seperating how good someone is at a skill from how that skill is actually implemented.For example, in the above example, the defender armed only with a dagger should realize that trying to parry an axe with a dagger is very hard, so a better defensive move would be to dodge entirely.  But how hard is it to dodge something?  This in turn depends on how that attack is implemented.  Generally speaking, in order from easiest to dodge to least to dodge: thrusts, vertical swings, horizontal swings, diagonal swings.  So one may conclude that the best attack mode is to always throw diagnoal swings.  But there''s a price to be paid for this mode of attack.  A swing requires more effort to recover from the swing (making the attacker more vulnerable to a counter-attack), and they are also slower in execution (meaning that if both parties attempt to strike at the same time, an opponent wishing to thrust will have a better chance of landing his blow first).So I personally feel that skill alone should not determine damage.  In fact, I believe that attacker strength, weapon type, weapon mode (swing, thrust, etc.), how well you hit (skill vs. skill), defender "health" and location (and armor if any) are all factors of determining damage.  I''d recommend finding an indie PPRPG called, "The Riddle of Steel" for some good ideas on how combat can be implemented.  Another good PPRPG to look at is the "Hero System".