ID:1467100
 
I am currently working on Kaizoku's Combat Mechanics, I have a lot of stuff done already. This includes basic definitions, animation procedures, combos... I just started the current combat itself, but am not a mathematician, and I may lack some imagination sometimes.

I made my own formula but whenever I look at it, I feel it's horrible. Here's said formula:
                var/punch = round((((Strength*100)+(Corpulence*30))/((check.Combat.Corpulence+check.Combat.Strength)))/((power+1)-power))

Strength is self explanatory. Corpulence may not be as obvious but it's a representation of your body's endurance, muscle mass etc.
The damage a player deals is supposed to be highly based on his strength, and having a good body status as happens in real life, the force of a punch is increased.

Therefore, Strength would be the actual power of our player's hit, and Corpulence would be an additional buff.
Defensive power is as well determined by a player's Corpulence and Strength, in this case Corpulence is the actual defensive power and Strength is an additional buff.

The punches/kicks are chargeable, hence why the power variable. The longer you charge the harder you hit.

That's not everything yet (>_>), theres another factor to take into account, players Accuracy.
The accuracy of a hit is determined by the player's Accuracy variable, being this one the main stat into this part of the formula, in addition to a Concentration variable and an Intelligence variable, as secondary modifier.

The explanation to the Concentration var is rather simple. If you lack concentration, you won't hit in time your enemy, IRL, so same applies here.

Why Intelligence? Well, if you lack intelligence you won't even know where, how or when to hit somebody, IRL, so same happens here. The more intelligence the better the chance to land an attack will be.

And yet we get to the last part of the formula, Reflexes. The enemy's reflexes are a mix of Reflexes, Concentration and Intelligence, one having a higher impact on the formula than the others respectively.

Is there anyone smarter than me that can actually think of a way to make such formula, or who can at least provide me with the right directions to develop it?

Thanks beforehand.
This seems a bit more complicated than it maybe has to be

power + 1 - power will always end up as 1 I believe, so I'm not sure what you intended with that part.

var atk = (Strength * 100) + (Corpulence * 30)


this is what you currently have, but where did 100 and 30 come from? how does health work?

var atk = (Strength * 100) + (Corpulence * 30)
var def = check.Combat.Corpulence + check.Combat.Strength
var punch = round(atk / def / 1)


Thats what I get out of this so far, and dividing the result by 1 doesn't do anything.

It depends a lot on what you want.
In response to Kitsueki
You mixed up the order of operations. The power+1 is a divisor, and he's subtracting power from the end result of the rest of the calculation.

Regardless, you(OP) seem to be going a bit ham on this. It seems like a very overly complicated system for something that is relatively simple, but here goes.

For accuracy, calculate the chance to hit, perhaps by simply adding concentration + accuracy + int + a dice roll, then do the same for the defender's dodge and if the attack misses, you stop there. You do the hit check first to avoid unnecessary calculations for the damage if they miss.

For the actual damage, that depends heavily on how you want your game to work. Is getting hit a big deal? How many hits are you expecting equal level mobs to be able to exchange before dying? Is combat just going to be "stand in front of the other guy and spam attack until someone wins" or will actually hitting something require player skill and be avoidable by the defender outside of just randomly dodging.

If it's just a game where you stand in front of eachother and spam attacks, you're basically just doing a stat check anyway, so making it complicated is pointless. Just go attacker.str - defender.def + dice roll

If you're going for a more skill based game where individual hits are earned and need a particular value, you would want to figure out the balance that you want.

You could go with a high stakes battle where every hit does a decent chunk of damage and avoiding hits is your highest priority. In this case you would want to figure out how much health your players will have and how much of it you want to be lost on being hit. This wouldn't be such a cut and dry formula like the previous example, your defense would do less, while your offense would do more. A decent idea would be having your defensive stats remove a percentage of damage based on a log scale.

You could have lots of smaller hits that take place over the course of a longer fight wherein individual mistakes aren't a big deal, but the overall skill of a player is more important. For this you would want your defense to have a higher impact on the damage, again probably going with a percentage, but with better scaling.

With either of these two, you're going to have to balance it out with play testing. Get some people together and just screw around with stats and equipment until you find something you like, then fine tune it.
/((power+1)-power)


This is the same as x / (power + 1 - power)
In response to Kitsueki
@Kitsueki: (power+1)-power <- This actually returns 1, my original intention was to substract from the maximum power, there's a typo, the actual division would be 'x/((MAX_PUNCH_POWER+1)-power)'
This is part of the charge calculation.

@Robertbanks2 You gave me a neat guideline to base my decissions on. I am now more concerned about the actual formula. To what extent is (Strength-Defense) accepted, I elaborate, when someone thinks about damage calculations, me in this case, expects an wtfwhat-long-understandable mathematical operation that just lifts you off your feets.
So, I will be putting an example, random operations for a formula, really, I don't know what I'll be doing in this exmple so bear with me:
var damage = (((atk+def)/(atk-def)) + (0.01*multiplier+1) + (0.005*(multiplier2+multiplier3))*(1+0.01*modifier)


In the extremly case this example would even make sense, how effective would it be, against for example this other:
var damage = (((atk+(atk*atk_mult))-(def*def_mult))*(0.1*modifier))+roll("2d6+15")


Maybe I am overheating myself about this when it's not that important, I am a bit lost here.
One thing I'm going to say is this.

Don't write code that looks like ((((((((((((((((((((stat))))-1*(((29+9))/76))+22))))))

Split it up into multiple lines. Trust me, in a few months when you come back to it you'll thank me when you don't have to spend hours decoding exactly how damage is calculated. (Getting balance in a game right is very hard, once you start testing you are going to have to come back and make minor changes to this)
I guess I will do a basic formula and as you say, testing will balance it itself. Maybe I were overrating myself thinking I could make a perfect shot with a singl try.

Anyways, is there any good source of information about formulas?
For damage calculations? Millions of them, all over the internet. But at the end of the day they all boil down to one thing.

damage = attack - defense

That is it. You don't particularly need a lot else, but if you want to make it more complex, attack should be the sum total of every offensive stat, while defense is the sum total of every defensive stat.

You use strength and weight to calculate damage?

attack = strength + weight

By adding a thousand other variables to the equation, you're just making it needlessly complex, but you're not achieving anything different.

If you want to know how I calculate damage. I use this...

attack = strength + (strength/10)**2

What this means is, the more strength the player has, the more effective the next point is.
10 strength = 11 damage
20 strength = 24 damage
30 strength = 39 damage
...
100 strength = 200 damage

As for defense, personally I tend to convert it to a percentage damage reduction, because I find tracking defense values through an entire game is a pain.

So for me damage ends up being calculated as...

attack = strength + (strength/10)**2
damage = attack * (defense/100)
damage = rand(damage*0.9,damage*1.1)

That is it. In this case, 50 defense results in 50% damage reduction, and 90 defense is 90% damage reduction. If you know what the maximum defense possible is (lets say 9999), then you can simply do defense/9999. That way 9999 defense is 100% damage reduction, while 4999 is 50%.


One thing I will say though. Unless you're converting defense into a percentage reduction like above, try to avoid using divisions for damage calculations. It can result in some very unpredictable numbers with an insanely large damage spread.

There is no need to make everything insanely complex you know?
This is how I calculate regular melee damage

mob/proc/attacked(mob/Attacker, damage = 1)
var Damage = max(0, damage * ((Attacker.BP * Attacker.Strength) / (BP * Durability)))


I'm sure we all understand BP, Strength, and Durability
the damage variable is a multiplier, which is upped to like 2 for example, when the attacker dashed in and attacked (heavy attack)

It's a simple equation, just..

attack = offset1 * strength
defense = offset2 * durability
damage = max(0, damage * (attack / durability))
In response to Kitsueki
I don't really understand BP.
In response to Kitsueki
So it is. I'm a blind moron. Sorry for the mistake. xD

Just shows the truth in the magic man's comment about the huge lines of math.
In response to Albro1
It stands for "beer power".
In response to FIREking
It only factors into calculations when your player has adopted the drunken monkey stance.

But it's basically another statistic, Albro. You add more, called 'mojo', 'groove' and 'funk' if you like, because as The Magic Man rightly points out, it ultimately boils down to a much simpler equation where all but the biggest components of growth are largely irrelevant to the calculation (and so, to the discerning meta-gamer's strategy). Hence min-maxing.