|
Hello dear reader!
If you're here because you feel you're a math genius :D GREAT! else not so great but thanks for reading! I'm currently making an indie RPG game and I'm at the point of my battle system in my game that I need to have a formula to calculate the amount of damage inflicted on the target.
I have my own thought up formula for calculating damage which works decently but damage is significantly different within each level and I figure that there are math geniuses here on TL that could very likely think up of a better way (or a programmer :D).
So I'm asking you as a math genius if you can think of a decent formula with the above attributes in mind that doesn't increase exponentially for each level. I will use the same for magic attacking and healing spells, just have to switch some modifiers then I think. So help me out! :D
My current formula is the following: ( ( (CharAttackingLevel * 10 ) + ( CharAttackingLevel * CharAttackingPower ) + ( CharAttackingLevel * CharAttackingBasePower ) ) - ( ( CharDefendingLevel * CharDefendingDefense ) + ( CharDefendingLevel * CharDefendingBaseDefense ) ) ) + RandomDamage
Notes: CharAttackingLevel: Character level that's attacking CharAttackingPower: The amount of attack power the character that's attacking has CharAttackingBasePower: The base amount of attack power of the character attacking RandomDamage: random number between 0 and 10 x CharAttackingLevel CharDefendingLevel: Character level that's defending. CharDefendingDefense: The amount of defense power the character that's defending has. CharDefendingBaseDefense: The base amount of defense power of the character attacking
I tried to attack with my characters a couple of dozen times and it seems pretty random. However it's quite significantly random as in the more attack power combined with level against lesser base defense the more damage significantly a character does and I prefer to avoid this as I'll also use this formula for my monsters against my characters.
Reason for this is because a level 3 character did a 98 damage (crit?) while a lvl 1 did 12 damage and they have same amount of attack power / defense power against a level 1 target monster. The difference is the level that they're attacking with obviously and because of the high modifier I listed.
Feels like once a character hits lvl 5 it's already hitting 500+ or more with basic stats. And it can occur that the amount of damage it generates can become negative. I want to have a decent formula but I don't know how to think up of one and that's where you math genius come along! :D So help me out
|
i've never seen how a video game is made in my life, but it seems there would be a problem with the last line + RandomDamage when you stated that RandomDamage= random # 0-10xCharAttackingLevel. That means for lvl 1's they either get +1 or +0 no matter what random number they pull.
seems odd to me also how you take into account both the CharDefendingDefense + the CharDefendingBaseDefense. Wouldn't it be much easier to completely take out the CharDefendingBaseDefense and just go purely off of CharDefendingDefense?
|
Well if you're going to add a random number you can't really complain about damage being irregular!!!You need to add a variant between a range(maybe it increases with level or w/e),usually most programming languages can generate a sudo random number within a certain rage with a function.
But for starters,try organizing your thread and putting the Problem up front,the information is quite disperse amidst your paragraphs!
|
@Sillidons: the randomDamage is the generated random number ranging from 0 till 10 times attacker level. So for a level 1 it's always going to be from including 0 till excluding 10 (0 - 9 will be the additional random damage for a level 1 and 0-18 for level 2 etc)
Well I was thinking if the user has no attacking power from items then he won't do any damage. The base attacking power would make it so that the attacker at very least does some base damage.
@mrafaeldie12: I'm not complaining about irregular damage Just wanted a better formula as I'm not a math genius myself :D
Okay thanks for the tip! :D will put up the problem on top :d
|
Every k is a constant that you define by experimentation.
Defence% = (1- ( 1/(k * CharDefendingDefense) ) )
RawRegularDamage = sqrt ( k * CharAttackingLevel * CharAttackingPower )
PeircingDamage = sqrt ( k * CharAttackingLevel * CharAttackingBasePower )
Defence = k * ( k * CharDefendingLevel + CharDefendingBaseDefense )
FinalRegularDamage = RawRegularDamage - Defence (can't be less than 0)
FinalDamage = (FinalRegularDamage + PeircingDamage + RandomDamage) * Defence% (then round)
A system based off both wc2 and wc3 damage systems, I've read about them both and incorporated what i thought was the best way to take your inputs and apply what i know from them and two rules:
Make things simple (for yourself), so try not to have many operations in one equation.
Make things linear (or less). if you multiply two variables together squareroot before doing anything else.
I'd love to hear if this system helps. You had alot of variable you wanted to include, I wasn't sure how you wanted them to work, but i tried my best to make an equitable system.
|
On January 06 2012 19:24 jrkirby wrote: Every k is a constant that you define by experimentation.
Defence% = (1- ( 1/(k * CharDefendingDefense) ) )
RawRegularDamage = sqrt ( k * CharAttackingLevel * CharAttackingPower )
PeircingDamage = sqrt ( k * CharAttackingLevel * CharAttackingBasePower )
Defence = k * ( k * CharDefendingLevel + CharDefendingBaseDefense )
FinalRegularDamage = RawRegularDamage - Defence (can't be less than 0)
FinalDamage = (FinalRegularDamage + PeircingDamage + RandomDamage) * Defence% (then round)
A system based off both wc2 and wc3 damage systems, I've read about them both and incorporated what i thought was the best way to take your inputs and apply what i know from them and two rules:
Make things simple (for yourself), so try not to have many operations in one equation.
Make things linear (or less). if you multiply two variables together squareroot before doing anything else.
I'd love to hear if this system helps. You had alot of variable you wanted to include, I wasn't sure how you wanted them to work, but i tried my best to make an equitable system. Hey man, :o I figured 3d games would have complicated formula's :D I can work with that thanks man!
Thanks for the tips, much appreciated :D will post later how the formula has worked out :D
|
I don't know why you want both character attacking level and character attacking power to be factored into the equation. Presumably higher level characters will have higher attacking power from items or something, so you have double scaling on the damage and this makes the numbers much harder to fine tune. Instead, just make levels add to your attacking power stat and take raw character level out of the equation, this is how it works for almost every game ever, it'll simplify things and make then numbers much easier to fine tune and less prone to huge variation. Same goes for defense.
|
On January 06 2012 19:39 UniversalSnip wrote: I don't know why you want both character attacking level and character attacking power to be factored into the equation. Presumably higher level characters will have higher attacking power from items or something, so you have double scaling on the damage and this makes the numbers much harder to fine tune. Instead, just make levels add to your attacking power stat and take raw character level out of the equation, this is how it works for almost every game ever, it'll simplify things and make then numbers much easier to fine tune and less prone to huge variation. Same goes for defense. I see, that is indeed better. I don't want to fine tune numbers on things like this Thanks for the suggestion. Will change the equations then.
|
On January 06 2012 19:39 UniversalSnip wrote: I don't know why you want both character attacking level and character attacking power to be factored into the equation. Presumably higher level characters will have higher attacking power from items or something, so you have double scaling on the damage and this makes the numbers much harder to fine tune. Instead, just make levels add to your attacking power stat and take raw character level out of the equation, this is how it works for almost every game ever, it'll simplify things and make then numbers much easier to fine tune and less prone to huge variation. Same goes for defense.
Honestly I would have taken many of his variables out as well, such as character level. But he said he wants to use them. So I thought of an interesting way to include them using concepts I learned from famous games. And since I didn't know how his game worked, I added many spots for him to add constants to tweak the system appropriately.
Also, @OP, if instead of just adding the random damage, you could take it out, and then at the end choose a number between FinalDamage/2 and FinalDamage. This is a trick in wc2's damage system. But in the formula I told you to just add it in near the end because that was what you were doing originally.
|
Is there a design reason why you're coming up with this obscure, convoluted way of calculating damage that the player will probably never understand and be able to consider as part of his strategy during combat without doing extensive math?
You don't need a math genius at all, you just need to keep things simple because that is the foundation of good game design. A few good guiding principles:
- Things should be kept simple to the point where a player can both understand level progression AND be able to instantaneously tell how much damage will his characters' attack deal to the creature, without consciously doing math. - Don't add arbitrary attributes that increase the complexity of calculations but don't add to the depth of gameplay (in particular, most attack skill / defense skill stats I've seen in various games I played have been completely redundant and could have been easily avoided). - Keep the numbers low, preferably in double digits, so that the human brain can process calculations spontaneously without requiring the player to actively think about it and distracting him from the game experience.
Consider this situation: - Your character does 5-7 damage with his Broadsword. The opponent has 10 health and 3 armor (damage reduction). You instantly know, without having to consciously consider it, that you'll be able to do 2-4 damage to the opponent, it's extremely intuitive.
With more complex calculations, you usually have to make a choice between revealing how the mechanics work - which will cause your players to actually work out the calculations before / during combat (if turn based) or during the leveling process when they make their choices regarding character progression - OR hiding the mechanics behind simple tooltips like 'this attack will cause 37-54 damage to this creature" (where the game does the calculations under the hood, and only displays results to the player) - in this case, the player has no real understanding of the mechanics of the game and the decisions he makes.
Do yourself a favor and don't follow the flawed design philosophies of the 90s RPGs. Simplicity is your friend!
|
that is not what a mathmatician do. sorry
|
On January 06 2012 19:50 jrkirby wrote:Show nested quote +On January 06 2012 19:39 UniversalSnip wrote: I don't know why you want both character attacking level and character attacking power to be factored into the equation. Presumably higher level characters will have higher attacking power from items or something, so you have double scaling on the damage and this makes the numbers much harder to fine tune. Instead, just make levels add to your attacking power stat and take raw character level out of the equation, this is how it works for almost every game ever, it'll simplify things and make then numbers much easier to fine tune and less prone to huge variation. Same goes for defense. Honestly I would have taken many of his variables out as well, such as character level. But he said he wants to use them. So I thought of an interesting way to include them using concepts I learned from famous games. And since I didn't know how his game worked, I added many spots for him to add constants to tweak the system appropriately. Also, @OP, if instead of just adding the random damage, you could take it out, and then at the end choose a number between FinalDamage/2 and FinalDamage. This is a trick in wc2's damage system. But in the formula I told you to just add it in near the end because that was what you were doing originally. Yea I've simplified things and now I'm only using 2 variables which is attacking power and defending power.
On January 06 2012 19:50 Talin wrote: Is there a design reason why you're coming up with this obscure, convoluted way of calculating damage that the player will probably never understand and be able to consider as part of his strategy during combat without doing extensive math?
You don't need a math genius at all, you just need to keep things simple because that is the foundation of good game design. A few good guiding principles:
- Things should be kept simple to the point where a player can both understand level progression AND be able to instantaneously tell how much damage will his characters' attack deal to the creature, without consciously doing math. - Don't add arbitrary attributes that increase the complexity of calculations but don't add to the depth of gameplay (most attack skill / defense skill stats I've seen in various games I played have been completely redundant and could have been easily avoided). - Keep the numbers low, preferably in double digits, so that the human brain can process calculations spontaneously without requiring the player to actively think about it.
Consider this situation: - Your character does 5-7 damage with his Broadsword. The opponent has 10 health and 3 armor (damage reduction). You instantly know, without having to consciously consider it, that you'll be able to do 2-4 damage to the opponent, it's extremely intuitive.
With more complex calculations, you usually have to make a choice between revealing how the mechanics work - which will cause your players to actually work out the calculations before / during combat (if turn based) or during the leveling process when they make their choices regarding character progression - OR hiding the mechanics behind simple tooltips like 'this attack will cause 37-54 damage to this creature" (where the game does the calculations under the hood, and only displays results to the player) - in this case, the player has no real understanding of the mechanics of the game and the decisions he makes.
Do yourself a favor and don't follow the flawed design philosophies of the 90s RPGs. Simplicity is your friend! I have no idea how the 90s RPGs work tbh. I'm literally just thinking it on the fly and then simplify after. With input from you lovely TL people I can work much better on things I don't really want to think a lot about :D
|
United States24495 Posts
On January 06 2012 19:50 Talin wrote: Do yourself a favor and don't follow the flawed design philosophies of the 90s RPGs. Simplicity is your friend! I'm not going to say I disagree with your proposed style of damage calculation, but I'm not sure if I agree that the way the "90s RPGs" did it was necessarily bad either. Being able to calculate details regarding the damage you can do is not necessarily part of a well designed battle system.
|
If you are using spells, you might also want to give some thought to how you will calculate damage from those. The player will expect a different set of factors to be represented in a spell than in an attack.
A simple way of setting priorities for what you expect out of your combat formulas might be as follows:
1) You want them to represent everything the player expects will be contributing to the end result, and nothing that they won't. For example, a player will be very disconcerted if their axe isn't taken into account in the attack calculations, and confused if it is taken into account when casting a healing spell. Think about what the player expects to happen, and try to make the formulas represent that in a simple way.
2) Keep the formulas simple so that you understand them, so that you can more easily tune them, and to ensure that you are not including unnecessary factors that don't fit with point number one.
3) Make the formula scale properly so you don't have people rocketing ahead of the curve or falling behind it.
|
I don't think a math genius is what you want here tbh...
|
|
On January 06 2012 20:36 UniversalSnip wrote: If you are using spells, you might also want to give some thought to how you will calculate damage from those. The player will expect a different set of factors to be represented in a spell than in an attack.
A simple way of setting priorities for what you expect out of your combat formulas might be as follows:
1) You want them to represent everything the player expects will be contributing to the end result, and nothing that they won't. For example, a player will be very disconcerted if their axe isn't taken into account in the attack calculations, and confused if it is taken into account when casting a healing spell. Think about what the player expects to happen, and try to make the formulas represent that in a simple way.
2) Keep the formulas simple so that you understand them, so that you can more easily tune them, and to ensure that you are not including unnecessary factors that don't fit with point number one.
3) Make the formula scale properly so you don't have people rocketing ahead of the curve or falling behind it. Ya I did like Talin said and just did attacking power - defense to start simple for attacks. And then I coded each level will now give a constant amount of attacking power and defending power to the player/monsters. This way it's simple to keep track of the amount of damage they'll take/receive and what a player can expect.
I'll actually do the same with magic power except the constant amount that is added each level is higher than attack.
And sorry guys for those saying that a mathematician doesn't do this :D It looks like math so I asked for a mathematician
Anyways, I thank everyone for giving their input. It has been really helpful so far ^^
Edit: I've actually been to some other site that gave similar answers (stackoverflow *cough*). It was just too much for my head at the time. Hmm should probably go rest and stop coding for few hours ^^
Thanks for the link. Will be helpful!
|
I started writing a comment, then realised it was turning into a wall so I've put in spoilers. Got a little carried away.
Pretty much I agree that rough calculations on the player side should be possible on the fly, but don't think there's any need for players to actually see the inner workings of combat or be able to completely predict the outcome. A system that is conceptually simple with a lengthier implementation is likely to be easier to fine tune or extend than the simplest system you can implement. And your first-try system is a decent enough starting point when rewritten for simplicity.
Simplifying what is there: + Show Spoiler +Unless there's a concrete reason to have ***BasePower values seperate to ***Power values then there should only be ***Power, with ***BasePower used as the initial value then modified as you level.
This yields:
Damage = ( (CharAttackingLevel * 10 ) + ( CharAttackingLevel * CharAttackingPower ) + RandomDamage) - ( CharDefendingLevel * CharDefendingDefense )
Given your definition of the random damage component this can be rewritten as:
Damage = CharAttackingLevel * ( CharAttackingPower + Random[Range=11..20] ) - CharDefendingLevel * CharDefendingDefense
This formula is a decent start because it is very simple (though it was initially written in a more complicated than necessary manner), and very modifiable.
Comments on random damage + Show Spoiler + The Random function you use and the range assigned are the first things to look at finetuning. Personally, I might consider using a probabilistic function instead of a random number generator and using that to edge the damage towards the low end. That would give scope for "lucky" items to be used to increase the chance of doing a critical amount of damage. I might also have a seperate function for the defending character to boost their defense in the same way. Because I hate the player, I would probably give a chance that you mess up an attack or a defense to the random function.
This would give something like:
Damage = CharAttackingLevel * ( CharAttackingPower + CharAttackingModifier ) - CharDefendingLevel * ( CharDefendingPower + CharDefendingModifier ) Where the modifiers are random or probabilistic functions whose ranges and distributions are adjusted by any factor that you want to affect the outcome.
Armour would shift the range of the defense modifier towards the positive and piercing damage might cause the armour bonus to be ignored.
All the complicated maths is hidden in the modifier functions and all the player needs to know is that item X will make critical hits 3x more likely, or bronze armor reduces damage by 2, or fighting in a tree makes dwarves more likely to miss because they're freaked out by heights. Because the modifiers can be different for every character you should have a lot of scope for balancing fights at various levels.
Level1 damage vs Level 3 damage + Show Spoiler +You got such a big increase between level 1 and level 3 because you multiply everything by the attacker or defender level. Level 3 in your original equation would always have at least 20+2*attackingpower more damage than the level 1 disregarding random. To avoid this then you could use the modifier to reduce the rate of damage increase (perhaps including a logarithmic part) or preferably restrict the use of the level in damage calculation.
Example: Damage = ( CharAttackingLevel * CharAttackingPower) + CharAttackingModifier - ( CharDefendingLevel * CharDefendingPower ) + CharDefendingModifier
The random part is no longer magnified greatly at higher levels, though you're free to have level modified components in it.
I would actually prefer for levels to not be directly used in damage calculation, and to use them when modifying stats like the attack power instead. Damage = CharAttackingPower - CharDefendingPower + GreatSecretCombatModifier
With somthing like: LevelUp Prereqs: Delta(Character{Level,AttackingPower,DefendingPower}) Postconditions: Level' = Level + 1 CharAttackingPower' = CharAttackingPower + Level CharDefendingPower' = CharDefendingPower + Level [ AttributeName' = new value of AttributeName]
Complicated 3D stuffz + Show Spoiler +Your damage function should be about as complicated as your fight. If there are lots of different types of item you can use to attack with/defend with/help your character to win and lots of ways to reliably use the terrain to get an advantage then your modifier function should be complicated enough to take all of that into account, whereas if there are few factors affecting a fight it should be extremely simple. Whether there is any need for a 3D component to enter into it depends on whether the orientation and inclination of a player or attack is affected by it.
Something like Tekken uses a simple slightly-more-than-2D approach to determine if blocks will work. That kind of system can be implemented easily enough by having attack-high and attack-low being calculated slightly differently (a helmet might not figure into defense against a low attack).
Unless your player has a huge amount of control over the way they attack and defend there's no point in trying for full 3D fighting. If a player can reliably move around their opponent in every dimension and hit any weak spot they find then having a fully three-dimensional combat system would definitely be justified - with characters, weapons and armor defined for damage or defense at any point and 3D physics used to calculate the forces between sword and shield, etc. At this point you would be simulating combat as if the player was the character and had the control to deliberately aim for the joins of a suit of armor.
If your controls aren't that fine, then you can save yourself a lot of effort. I have yet to play any game that gives you the degree of control that would make such a combat system shine.
|
okay :
CharAttackingLevel: CAL CharAttackingPower: CAP CharAttackingBasePower: CABP RandomDamage: RD CharDefendingLevel:CDL CharDefendingDefense: CDD CharDefendingBaseDefense: CDBD
Your formular : ( ( (CAL* 10 ) + ( CAL * CAP ) + ( CAL* CABP ) ) - ( ( CDL * CDD) + ( CDL * CDBD ) ) ) + RD
= CAL * (10+CAP+CABP) - CDL *(CDD + CDBD) + RD
This makes it pretty obvious why the CAL has such a huge impact (and maybe easier to find a better solution)
Now how to change this? Well Im not sure , you could try these ideas :
1.Idea switch any of (10+CAP+CABP) with CAL and try if it works better CAP *( 10 + CAL + CABP ) - CDL *(CDD + CDBD) + RD More emphasis on CAP , less on CAL CABP* (10+CAL+CAP) - CDL *(CDD + CDBD) + RD Neither CAL nor CAP change the outcome dramatically 10 *(CABP +CAL+CAP) - CDL *(CDD + CDBD) + RD Problem: Damage can still become <0 , but Im sure there is a programming trick where you can say if Damage becomes negative => Damage = 0
2. Idea This"-" sucks, try using "/"
[ CAL * (10+CAP+CABP) / CDL *(CDD + CDBD) ] +RD this of course gives you comma numbers, so idk if you can round them up
I just read you changed your system. So all of this will be pretty useless. Anyways GL coding.
|
On January 06 2012 22:23 Kleinmuuhg wrote:
2. Idea This"-" sucks, try using "/"
[ CAL * (10+CAP+CABP) / CDL *(CDD + CDBD) ] +RD this of course gives you comma numbers, so idk if you can round them up
Using '%' instead of '/' returns an integer.
|
|
|
|