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

Started by
14 comments, last by superpig 16 years, 11 months ago
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.
Advertisement
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).

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

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

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

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 ?
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.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement