# Trying to figure out how much damage to inflict....

## Recommended Posts

vaneger    100
I never took physics so i'm unfamiliar with how things work. I'm working on a combat model for a game where characters have a weight and a speed, but I don't know how that corralates to how much damage they might be able to do with a punch, or using a melee weapon.

##### Share on other sites
I love the title for this. I think the mods need to move it to this forum. I think you might have better luck there.

##### Share on other sites
Palidine    1315
It's not at all related. That's a specifically design oriented decision. You just make a guess and then tune a number until the game plays the way you want it to play.

To get actual real world "damage" simulation you'd have to model the entire human body ( bone mass & density, blood flow, anatomy, all the thousands of different muscle groups, etc). Science doesn't even know enough to accurately predict "damage" to the level of specificity that would be needed in a game.

For instance, throw people out out of a plane with no parachute. 99.999% will die instantly. at least one guy will live (plenty of stories & videos of people just hitting the ground after a 20,000 foot fall and just bouncing and walking away with a bruise). Reality is far too complicated and random to model for a game.

Game design and programming is 100% about cheating, hacking and making up bullshit algorithms that appear to the user to be accurate simulations of reality.

-me

##### Share on other sites
vaneger    100
I know games generally make stuff up, and I'd be fudging the numbers too, but I'm just trying to figure out how weight and speed would contribute to how much damage a 250 lb boxer might do to an unfortunate 100 lb guard.

##### Share on other sites
superpig    1825
It breaks down as soon as you start trying to consider what units to measure "damage" in. Most games use a character-wide "health" value which is just an arbitrary number - so already we're making things up for this system.

But still, being realistic is not as important as being fun.

What one does is to design a formula for damage - it will take things like the masses and velocities of the characters, as well as a bunch of 'arbitrary numbers' that tweak the way the output of the formula changes as you change the masses/velocities - and then play the game over and over, changing the arbitrary numbers until it feels fun to play.

##### Share on other sites
Quote:
 Original post by mntlinstituteflrI love the title for this. I think the mods need to move it to this forum. I think you might have better luck there.

Actually, I Don't think it's a good idea. At lest for now, I think this forum is more apropriate. I mean, he isn't asking anything complicated (well, it IS quite complicated, but in a way that it's almost impossible to answer, while there are lots of easy ways to do it he hasn't asked for).

Anyway, back to the original poster question:
There is no physhics that can answer that. If you want to know, for instance, how much a character should move backward when he is punched (the heavier he is, the less he will move backward), then knowing physics will help you. But even in this case, the physics involved will be a little complicated, so a good aproach would be to just make the character go 10 inches back, for instance. If you want this to be proportional to the weight (well, you should use the mass actually), you just move it by 100/mass inches, and then you tune the numbers until you get an apropriate response.

Back to the damage/weight relation, there shouldn't be much. The damage will be proportional to the strenght the punch is made, this has no direct relation to the weight of one person. This doesen't mean you can't come up with a formula that simulates a condition where a heavy fighter is stronger then a light one, but we would need more information on how the game works.

Anyway, I would sugest you to take ome time to actually learn physics properly. Most of the time (well, that actually depends on your game), you will be hacking things so that they are simple to code but still look good on the screen, but when your problems get more complicated, good math and physics knowledge will help you a lot.

##### Share on other sites
iosys    139
It's a combination of innate attributes and skill/experience which would determine one's proficiency at something. For every small fry who can knock you out there's a meat head who throws his weight off balance.

I don't think physics is the answer here. Looking at an example from Street Fighter: Zangief is a big beefy guy who hits hard. The designers just thought "strong russian dude hurts you quick...give him 90 damage per jab." So they put in the value for his jab and play tested it. That's not a true account, but you get the idea.

You don't have to be so absolute. RPG's use "stats" and "weapon skill" to determine an overall range of damage that a player will deal with each attack. The strength of a player and the weight of an axe might determine the minimum and maximum damage he could do against an unarmored player. A player with armor and the ability to dodge or block would reduce the effectiveness of the axe wielder.

##### Share on other sites
vaneger    100
Well for non weapon attacks I plan on damage being a function of level, a percent of player strength, weight,speed and the attacks base damage value ( which me just be a scale from 1 thru 10 or 20).

##### Share on other sites
Antheus    2409
Calculating the attack energy is somewhat trivial compared to estimating the effect of impact.

Think crash test - supercomputers runs for days to produce a semi-accurate result for a small number of parameters. And those use decades of experiments on real human bodies, sampled down to every organ, to obtain empirical data - one which turns out to be completely specific to each gender, age, height, weight, ....

But if you have a single health bar, then all of that is irrelevant. Work out something that can be balanced and tweaked effectively.

Perhaps the most important question is whether you want to use linear model, or some form of exponential function.

Linear model simply means, 2x the attribute = 2x the damage. This scales somewhat well, but can lead to certain tweaks (11 in strength will kill someone in 2 hits, but 10 in strength will take 3).

Other way is to introduce some non-linear relation. For example, the probability of miss is sqrt(agility). So, a player with no agility has 0 chance of getting missed. Putting 10 adds a higher chance, going to 100 adds even more. But ultimately this chance to miss someone remains small, it rewards the player more at lower levels, but becomes less effective at higher, meaning that not investing much into agility doesn't punish the player as much.

This non-linear scaling also works somewhat better for some relations, since some physical relations scale non-linearly.

Consider a punch. The stronger you are, the faster you can punch, but ultimately, air resistance would become a problem, and air resistance is non-linear. I'm sure that strength/muscle mass relation is similar. Doubling muscle mass probably doesn't result in double impact force, since muscle has some volume, but strength comes from cross section. So the energy used is probably invested into entire volume of the muscle, but only cross section contributes to force of impact (I don't know, just brainstorming here). More body mass also means more energy needed to start the punch, so the punch probably reaches lower speed at time of impact, and so on...

##### Share on other sites
erissian    727
It depends on how complex you make the game. Are you just doing two bodies, two health bars, and generic damage? Do you do hit locations? Does the character develop its skill over time?

In the simplest model, I would have damage be proportionate to strength and skill. Speedier characters just get to deal a higher rate of damage. Damage dealt and especially speed should decrease along with health.

##### Share on other sites
vaneger    100
Well here's what I've worked up so far. Any one see any glaring problems ( like if the functions return too high or too low results if a given stat is tweaked)?
class c_Stats{	public:		//c_Stats();		//~c_Stats();		int currentHP, maxHP, currentEnd, maxEnd, strength;		int accuracy,defense, resistance, weight;		float speed;		bool NPC;};c_Stats ini_func(int acc,int str,int weight,int speed,int def,int res, bool npc){	c_Stats newStats;	newStats.maxHP = 100;	newStats.currentHP = 100;	newStats.currentEnd = 100;	newStats.maxEnd = 100;	newStats.defense = def;	newStats.resistance = res;	newStats.accuracy = acc;	newStats.strength = str;	newStats.weight = weight;	newStats.speed = speed;	newStats.NPC = npc;	return newStats;}int damage_calc(c_Stats attacker,int attack){	int dam = 0;	float level_mod, str_mod,spd_mod,end_mod = 0.0;		level_mod = 1 + (50/50.0);	end_mod = (attacker.currentEnd / attacker.maxEnd) / 100.0;	str_mod = (attacker.strength * end_mod ) * level_mod;	spd_mod = attacker.speed * end_mod;		dam = (1 + level_mod) * (1 + str_mod) * (1 + spd_mod) * attack;	return dam ;}float weighted_damage(c_Stats AT, c_Stats DF,int attack){	float dmg = 0.0;	float wgt_mod = 0.0;	float wgt_dif = AT.weight / (1.0 * DF.weight);	dmg = damage_calc(AT,attack);	wgt_mod = (AT.weight - DF.weight);	wgt_mod = wgt_mod / AT.weight;	if(wgt_mod < 0)		dmg = dmg * (wgt_dif);	else		dmg = dmg * (1 + wgt_mod);	return dmg;}AT = ini_func(75,255,150,255,5,10,false);DF = ini_func(50,210,10,275,5,10,true);cout<<weighted_damage(AT,DF,50)<<endl;

the level mod would be from 1-50 instead of always 50, I just havent added a level attribute yet.

##### Share on other sites
superpig    1825
That depends on what you call 'too high or too low.' The damage function is unbounded in terms of strength, speed, and attack, so you can make any of those variables arbitrarily high to get a high damage value.

(From a code quality point of view, though, there's room for a lot of improvement. Ask if you want feedback on that as well as the logic).

##### Share on other sites
vaneger    100
well player stats will be bounded at 255 aside from HP and weight.

This code is just a rough job to come up with an equation for damage so I know how all the stats will work out together.

##### Share on other sites
superpig    1825
In that case, damage_calc will return a value in the range [0, 64.965 * attack].

It would probably be helpful to create some 'sample characters' that range across the different strengths of units - humble villager through to chaos knight or whatever - and see how much their different combinations of stats produce different damage values. It can help to establish equivalences - for example, a level 1 character with all stats maxed out deals equal damage to a level 2 character with all stats maxed out except speed or strength = 246, etc. Excel would be helpful.

##### Share on other sites
vaneger    100
Well thats good to know ( attack value will be limited to >=50 for most cases)
so ~3250 damage max, which fits nicely.

I'm not sure what values would be 'base line' for an average human though, any ideas on that ?

##### Share on other sites
superpig    1825
Well, that's the thing - all these values are completely arbitrary. It won't be the values themselves as much as the proportions that will matter.

I think you need calibration points, which is what I was hinting towards in my last post. Figure out what the least powerful creature in your game is, and set it with all stats on minimum, and then figure out what the most powerful creature in your game is and set it on maximum. Then start placing others using those - e.g. 10 plague rats should be able to take down a horse in about the same time as a swordmaster, so the damage of 1 plague rat should be about 1/10th that of a swordmaster, etc.

## 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